I am working on a project that involves using the Selenium WebDriver and a specific Firefox Profile heavily to find elements and manage the page.
For example,
driver.findElement(By.xpath("//*[@id='foobar']"));
anddriver.manage().refresh();
I am trying to implement Selenium Grid into my project; however, with the extensive use of Selenium WebDriver, is there a way to start the ThreadSafeSeleniumSessionStorage.session() static object with a specific WebDriver?
As far as I have researched, it is possible to get the WebDriver from the Selenium object by:
startSeleniumSession(seleniumHost, seleniumPort, browser, webSite); //Create and start the session() object
//TODO: insert a specific WebDriver into the session() object
WebDriver driver = ((WebDriverBackedSelenium) session()).getWrappedDriver(); //Get the WebDriver from the session() object
I have not tried this code but if it works then you would have an object that holds Selenium based WebDriver. As per my understanding this feature is there for migration from Selenium 1 to Selenium 2. This is not the recommended way to make web driver thread safe.
WebDriver by default is not thread safe. I would recommend to instantiate one WebDriver instance for each thread.
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