I'm testing selenium remote webdriver with grid and I got stuck with an error:
org.openqa.selenium.WebDriverException: Unable to bind to locking port 7054 within 45000 ms
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
System info: host: 'XXXXX', ip: 'XXXXX', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_45'
Driver info: driver.version: FirefoxDriver
Command duration or timeout: 47.71 seconds
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:02:37'
System info: host: 'XXXXX', ip: 'XXXXX', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_45'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Info about my configuration:
- selenium-server-standalone-2.45.0
- browser: Firefox esr 31.5.0
- I run tests with eclipe and testNG
Hub configuration:
{ "host": null, "port": 4444, "newSessionWaitTimeout": -1, "servlets" : [], "prioritizer": null, "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher", "throwOnCapabilityNotPresent": true, "nodePolling": 5000, "cleanUpCycle": 5000, "timeout": 300000, "browserTimeout": 0, "maxSession": 100, "jettyMaxThreads":-1 }
I have three nodes with configuration like this:
{ "capabilities": [ { "browserName": "firefox", "maxInstances": 5, "seleniumProtocol": "WebDriver" }, { "browserName": "chrome", "maxInstances": 5, "seleniumProtocol": "WebDriver" }, { "browserName": "iexplorer", "maxInstances": 1, "seleniumProtocol": "WebDriver" } ], "configuration": { "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy", "maxSession": 10, "port": 5555, "host": ip, "register": true, "registerCycle": 5000, "hubPort": 4444, "hubHost": ip } }
My question is: what could be the reasons for this error? For the moment I don't even understand why there is locking port 7054 even if my hub and nodes configuration ports are different.
Thanks for your time and answers.
UPDATE:
@BeforeMethod and @AfterMethod functions
@BeforeMethod
public void setUp(){
StringBuilder text = customAppender.createInstance();
customAppender.setBuilder(text);
WebDriver driver = LocalDriverFactory.createInstance("firefox");
LocalDriverManager.setWebDriver(driver);
customAppender.append("Opened webDriver instance = " + driver.hashCode());
}
@AfterMethod
public void shutDown(){
WebDriver driver = LocalDriverManager.getDriver();
if (driver != null) {
mainFunctions.log("Closed webDriver instance = " + driver.hashCode(), 2);
driver.quit();
}
}
@Test methods:
@Test(dataProvider = "getData")
public static void test(String browserName, String link) throws MalformedURLException, InterruptedException {
WebDriver driver = LocalDriverManager.getDriver();
customAppender.append("Thread id = " + Thread.currentThread().getId());
customAppender.append("Hashcode of webDriver instance = " + driver.hashCode());
driver.get(link);
customAppender.append(driver.getTitle());
Thread.sleep(20000); // for testing purposes
customAppender.append("Test 1, time: " + new SimpleDateFormat("HHmmss").format(Calendar.getInstance().getTime()));
mainFunctions.log(customAppender.printOutString(), 0);
}
@Test(dataProvider = "getData")
public static void test2(String browserName, String link) throws MalformedURLException, InterruptedException {
WebDriver driver = LocalDriverManager.getDriver();
customAppender.append("Thread id = " + Thread.currentThread().getId());
customAppender.append("Hashcode of webDriver instance = " + driver.hashCode());
driver.get(link);
customAppender.append(driver.getTitle());
Thread.sleep(20000); // for testing purposes
customAppender.append("Test 2, time: " + new SimpleDateFormat("HHmmss").format(Calendar.getInstance().getTime()));
mainFunctions.log(customAppender.printOutString(), 0);
}
@DataProvider
@DataProvider(parallel=true)
public Object[][] getData(){
Object[][] d = new Object[4][2];
// dummy data
d[0][0] = "firefox";
d[0][1] = "http://www.google.com";
d[1][0] = "firefox";
d[1][1] = "http://www.google.com";
d[2][0] = "firefox";
d[2][1] = "http://www.google.com";
d[3][0] = "firefox";
d[3][1] = http://www.google.com";
return d;
}
testNG.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="methods" thread-count="20">
<test name="Test">
<classes>
<class name="ts.testWebdriver" />
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
the cause might be that your firefox instance via webdriver is running on that particular port on remote machine. Kill the ff instance and execute the test. Do provide driver.quit() at end of your test case to avoid these failures.