我是selenium webdriver的新手,我试图运行一个简单的测试: 我使用firefox 17.0.1和selenium 2.28使用旧版本的firefox和selenium,但它没有用。
但是我收到了这个错误:
[TestNG] Running:
C:\Users\Amira\AppData\Local\Temp\testng-eclipse--387650463\testng-customsuite.xml
FAILED: testApp
org.openqa.selenium.WebDriverException: Unable to bind to locking port 7054 within 45000 ms
Build info: version: '2.28.0', revision: '18309', time: '2012-12-11 15:53:30'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_05'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.internal.SocketLock.lock(SocketLock.java:94)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:72)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:244)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:188)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:183)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:179)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:92)
at GoogleNavigationTest.testApp(GoogleNavigationTest.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:128)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1203)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1128)
at org.testng.TestNG.run(TestNG.java:1036)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================
[TestNG] Time taken by org.testng.reporters.jq.Main@985016: 96 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@191c263: 22 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@4b7c69: 62 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@18e5ebd: 9 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@e5025: 8 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 9 ms
当我卸载firefox并安装它时,测试只能在第一次工作。
答案 0 :(得分:3)
我遇到了同样的问题。这个问题有几个解决方案:
首先,您应该使用:netstat -np TCP | find "7054"
- 如果端口很忙,你应该:
删除使用此端口的进程或为firefox设置其他端口,使用:`profile.setPreference(PORT_PREFERENCE,port);`
-if port is free:
答案 1 :(得分:2)
检查您的主机文件C:\Windows\System32\drivers\etc
。你有没有像这样设置
192.168.60.133 localhost:
删除它,然后尝试。
答案 2 :(得分:2)
确保您没有打开任何WebDriver Firefox窗口!
答案 3 :(得分:1)
你需要在任务管理器中结束java的过程,有时如果没有调用或执行driver.quit它会发生