2014-11-24 60 views
0

我與電網測試硒遠程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 --> 
+0

剛回到這種情況。還有其他建議嗎? :) – Rollaz 2015-07-02 13:39:59

回答

1

的原因可能是通過webdriver的Firefox的實例遠程計算機上的特定端口上運行。殺死ff實例並執行測試。在測試用例的末尾提供driver.quit()以避免這些失敗。

+0

感謝您的回答;) 我有driver.quit();在測試用例的最後,還有if子句:if(driver!= null) 我會檢查這是否可能是問題。 – Rollaz 2014-11-24 15:41:57

+0

'WebDriver driver = LocalDriverManager.getDriver();'創建新的驅動程序實例?如果是這樣,請查看shutDown方法,在這裏你試圖殺死從關機的第一行獲得的新驅動程序。謝謝。 – 2014-11-24 15:56:27

+0

不,'LocalDriverManager.getDriver();'正在返回webdriver實例: 'public class LocalDriverManager private static ThreadLocal webDriver = new ThreadLocal (); public static WebDriver getDriver(){ return webDriver.get(); } public static void setWebDriver(WebDriver driver){ webDriver.set(driver); } }' 實例與'LocalDriverFactory.createInstance( 「火狐」)創建的;' – Rollaz 2014-11-25 07:23:37

0

好吧,所以我用WebDriver有這個問題,但無法修復它。 儘管找到了解決辦法。 我創建了一個新的Windows用戶,並從該用戶運行測試。現在看起來不錯。祝你好運。

+0

只是在想如何能與Windows用戶有關..怪,對建議謝謝:) – Rollaz 2015-02-16 16:45:38

相關問題