i'm writing here to ask if is possible to init WebDriver
WebDriver driver = new FirefoxDriver();
and use the same browser for many jar application, so doing, in other jar file, something like:
int port = ...;
String host = ...;
WebDriver driver = getDriver(host,port);
i ask this question because FirefoxDriver is very slow to load and happear, and i need to call many jar that load that driver. i think that in this way, loading just one time my driver, my total application will be fastly than open N-times N-instances of that driver. i hope that my question is clear and well-formed :) thanks to all!
EDIT:
i see that there is the possibility to use RemoteWebDriver.
DesiredCapabilities capability = DesiredCapabilities.firefox();
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
How can i use it? when i have to instantiate the webdriver in localhost:4444?
This is the most demanded feature request in Selenium. However, it's still not possible to attach a WebDriver to running browser window. What you discovered in RemoteWebDriver is the posibility to run tests remotely on another computer. But that computer still has to start a new browser window.
You could, I guess, write your application as something as a HUB that would enqueue all jars (classes) to run, would start a single instance of Firefox and pass the driver reference around. It's not a nice solution and as far as I know, nobody has done it yet.
BUT! The majority of time spent on startup in Firefox is creating a new FirefoxProfile. If you created one profile dedicated to testing and started your Firefox always with this profile, it would be significantly faster.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With