我與電網測試硒遠程webdriver的,我卡住了一個錯誤鎖定端口7054:的webdriver 2.45.0和Firefox ESR 31.5.0 :: WebDriverException:無法綁定到內45000毫秒
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
信息關於我的配置:
- 硒的服務器獨立-2.45.0
- 瀏覽器:Firefox ESR 31.5.0
- 我運行的Eclipe和TestNG 測試
樞紐配置:
{ "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 }
我有這樣的配置有三個節點:
{ "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 } }
我的問題是:這可能是此錯誤的原因? 目前我甚至不明白爲什麼有鎖定端口7054,即使我的集線器和節點配置端口不同。
感謝您的時間和答案。
UPDATE:
@BeforeMethod和@AfterMethod功能
@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方法:
@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文件
<?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 -->
剛回到這種情況。還有其他建議嗎? :) – Rollaz 2015-07-02 13:39:59