I have this code for creating my web driver.
Now this code works fine if I create the driver 1 by 1.
The problem arises when creating these drivers on multiple threads.
public static WebDriver getConfiguredWebDriver(.....)
WebDriver driver = null;
DesiredCapabilities cap = new DesiredCapabilities();
if(ffp != null) {
ffp.setPreference("general.useragent.override", getRandomizedUASettings(rand, UserAgentList));
}
driver = new FirefoxDriver(null, ffp, cap);
//driver = new FirefoxDriver(); also gives an error of the same kind during multithreading
return driver;
}
It gives me this error
“Thread-4” org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(C:\Program Files (x86)\Mozilla Firefox\firefox.exe) on port 7057; process output follows:
null
Build info: version: ‘2.28.0’, revision: ‘18309’, time: ‘2012-12-11 20:21:45’
System info: os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.6.0_26’
The thread code is
while(...) {
....... //
FirefoxProfile ffp = new FirefoxProfile();
DataEntryThread t = new DataEntryThread(parentFrame, lead, new ProxySettings(proxySettings), ffp, UserAgentList);
t.start();
....... //
}
The error comes on any thread randomly and even the port number. What is wrong here ? How do I achieve loading multiple firefox drivers on different threads ?
I have found a work around for this.. just modify a part of the above code
Basically, I think the driver being loaded using different threads is accessing the same binary file of firefox at the same time which gives an error but I am still unsure of it.