Selenium jar:2.34,Firefox版本:22.0
请在下面找到代码:
FirefoxProfile firefoxProfile = new FirefoxProfile(new File("C:\\Users\\admin\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\dww46q4q.default"));
WebDriver driver = new FirefoxDriver(firefoxProfile);
driver.get("https://www.google.com");
Firefox浏览器启动,但它没有导航到google.com并且在一段时间后我得到此异常:org.openqa.selenium.firefox.NotConnectedException:无法在45000 ms后连接到端口7055上的主机127.0.0.1 。 Firefox控制台输出:
当我在不使用firefox配置文件的情况下启动firefox浏览器时,它运行正常,即启动firefox浏览器,导航到google.com并且不会发生异常
控制台输出
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
*** LOG addons.xpi: startup
*** LOG addons.xpi: Skipping unavailable install location app-system-local
*** LOG addons.xpi: Skipping unavailable install location app-system-share
*** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID:
C:\Windows\TEMP\anonymous3048824074469384020webdriver-profile\extensions\webdriver-staging
*** LOG addons.xpi: checkForChanges
*** LOG addons.xpi-utils: Opening database
*** LOG addons.xpi: Add-on FireXPath@pierre.tholence.com modified in app-profile
*** Blocklist::_loadBlocklistFromFile: blocklist is disabled
*** LOG addons.xpi: Add-on firebug@software.joehewitt.com modified in app-profile
*** LOG addons.xpi: Loading bootstrap scope from
C:\Windows\TEMP\anonymous3048824074469384020webdriver- profile\extensions\firebug@software.joehewitt.com.xpi
*** LOG addons.xpi: Calling bootstrap method install on firebug@software.joehewitt.com version 1.11.4
*** LOG addons.xpi: Add-on seleniumbuilder@saucelabs.com modified in app-profile
*** LOG addons.xpi: Add-on {5384767E-00D9-40E9-B72F-9CC39D655D6F} modified in app-profile
*** LOG addons.xpi: Add-on csharpformatters@seleniumhq.org modified in app-profile
*** LOG addons.xpi: Add-on javaformatters@seleniumhq.org modified in app-profile
*** LOG addons.xpi: Add-on rubyformatters@seleniumhq.org modified in app-profile
*** LOG addons.xpi: Add-on {a6fd85ed-e919-4a43-a5af-8da18bda539f} modified in app-profile
*** LOG addons.xpi: Add-on pythonformatters@seleniumhq.org modified in app-profile
*** LOG addons.xpi: New add-on fxdriver@googlecode.com installed in app-profile
*** LOG addons.xpi: Add-on {22181a4d-af90-4ca3-a569-faed9118d6bc} modified in winreg-app-global
*** LOG addons.xpi: Updating database with changes to installed add-ons
*** LOG addons.xpi-utils: Updating add-on states
*** LOG addons.xpi-utils: Writing add-ons list
*** LOG addons.xpi: Calling bootstrap method startup on firebug@software.joehewitt.com version 1.11.4
*** LOG addons.manager: shutdown
*** LOG addons.xpi: shutdown
*** LOG addons.xpi-utils: shutdown
*** LOG addons.xpi-utils: Database closed
*** LOG addons.xpi: startup
*** LOG addons.xpi: Skipping unavailable install location app-system-local
*** LOG addons.xpi: Skipping unavailable install location app-system-share
*** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID:
C:\Windows\TEMP\anonymous3048824074469384020webdriver-profile\extensions\webdriver-staging
*** LOG addons.xpi: checkForChanges
*** LOG addons.xpi: No changes found
*** LOG addons.xpi: Loading bootstrap scope from
C:\Windows\TEMP\anonymous3048824074469384020webdriver-profile\extensions\firebug@software.joehewitt.com.xpi
*** LOG addons.xpi: Calling bootstrap method startup on firebug@software.joehewitt.com version 1.11.4
*** LOG addons.xpi-utils: Opening database
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:106)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:251)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:197)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:190)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:103)
at pack1.downloadfile.test1(downloadfile.java:46)
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:84)
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:127)
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:335)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:330)
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:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
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)
FAILED: test1
org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(C:\Program Files (x86)\Mozilla Firefox\firefox.exe) on port 7055; process output follows:
*** LOG addons.xpi: startup
*** LOG addons.xpi: Skipping unavailable install location app-system-local
*** LOG addons.xpi: Skipping unavailable install location app-system-share
*** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID:
C:\Windows\TEMP\anonymous3048824074469384020webdriver-profile\extensions\webdriver-staging
*** LOG addons.xpi: checkForChanges
*** LOG addons.xpi-utils: Opening database
*** LOG addons.xpi: Add-on FireXPath@pierre.tholence.com modified in app-profile
*** Blocklist::_loadBlocklistFromFile: blocklist is disabled
*** LOG addons.xpi: Add-on firebug@software.joehewitt.com modified in app-profile
*** LOG addons.xpi: Loading bootstrap scope from
C:\Windows\TEMP\anonymous3048824074469384020webdriver-profile\extensions\firebug@software.joehewitt.com.xpi
*** LOG addons.xpi: Calling bootstrap method install on firebug@software.joehewitt.com version 1.11.4
*** LOG addons.xpi: Add-on seleniumbuilder@saucelabs.com modified in app-profile
*** LOG addons.xpi: Add-on {5384767E-00D9-40E9-B72F-9CC39D655D6F} modified in app-profile
*** LOG addons.xpi: Add-on csharpformatters@seleniumhq.org modified in app-profile
*** LOG addons.xpi: Add-on javaformatters@seleniumhq.org modified in app-profile
*** LOG addons.xpi: Add-on rubyformatters@seleniumhq.org modified in app-profile
*** LOG addons.xpi: Add-on {a6fd85ed-e919-4a43-a5af-8da18bda539f} modified in app-profile
*** LOG addons.xpi: Add-on pythonformatters@seleniumhq.org modified in app-profile
*** LOG addons.xpi: New add-on fxdriver@googlecode.com installed in app-profile
*** LOG addons.xpi: Add-on {22181a4d-af90-4ca3-a569-faed9118d6bc} modified in winreg-app-global
*** LOG addons.xpi: Updating database with changes to installed add-ons
*** LOG addons.xpi-utils: Updating add-on states
*** LOG addons.xpi-utils: Writing add-ons list
*** LOG addons.xpi: Calling bootstrap method startup on firebug@software.joehewitt.com version 1.11.4
*** LOG addons.manager: shutdown
*** LOG addons.xpi: shutdown
*** LOG addons.xpi-utils: shutdown
*** LOG addons.xpi-utils: Database closed
*** LOG addons.xpi: startup
*** LOG addons.xpi: Skipping unavailable install location app-system-local
*** LOG addons.xpi: Skipping unavailable install location app-system-share
*** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: