我无法通过硒启动FireFox。
当我创建FirefoxDriver实例时,错误打开。
public void startFireFox() {
driver = new FirefoxDriver();
}
firefox窗口是白页。就像Img一样。 [![在此处输入图像说明] [1]] [1]
错误日志是这样的。我该如何解决这个问题?
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 02:56:46'
System info: os.name: 'Windows 8.1', os.ar
ch: 'x86', os.version: '6.3', java.version: '1.8.0_60'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.st
art(NewProfileExtensionConnection.java:134)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.j
ava:276)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.jav
a:116)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:2
23)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:2
16)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:2
12)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:1
25)
at org.selenium.Browser.startFireFox(Browser.java:251)
at com.buyma.NewDisplay.initialSetting(NewDisplay.java:77)
at com.buyma.NewDisplayTool.actionPerformed(NewDisplayTool.java:130)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
ce)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionP
rivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionP
rivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionP
rivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: org.openqa.selenium.firefox.NotConnectedException: Unable to connect
to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
"appDisabled":false,"descriptor":"C:\\Program Files (x86)\\Mozilla Firefox\\brow
ser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}","installDate":144390787
7310,"updateDate":1443907877310,"applyBackgroundUpdates":1,"skinnable":true,"siz
e":22852,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignIn
stall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[]
,"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersio
n":"41.0.1","maxVersion":"41.0.1"}],"targetPlatforms":[]}
1444033838736 addons.xpi DEBUG getModTime: Recursive scan of {972ce4c6-
7e08-4474-a285-3208198ce6fd}
1444033838740 addons.xpi DEBUG Updating database with changes to instal
led add-ons
1444033838740 addons.xpi-utils DEBUG Updating add-on states
1444033838742 addons.xpi-utils DEBUG Writing add-ons list
1444033838788 addons.manager DEBUG Registering shutdown blocker for XPIProv
ider
1444033838789 addons.manager DEBUG Provider finished startup: XPIProvider
1444033838789 addons.manager DEBUG Starting provider: LightweightThemeManag
er
1444033838790 addons.manager DEBUG Registering shutdown blocker for Lightwe
ightThemeManager
1444033838790 addons.manager DEBUG Provider finished startup: LightweightTh
emeManager
1444033838791 addons.manager DEBUG Starting provider: GMPProvider
1444033838802 addons.manager DEBUG Registering shutdown blocker for GMPProv
ider
1444033838802 addons.manager DEBUG Provider finished startup: GMPProvider
1444033838802 addons.manager DEBUG Starting provider: PluginProvider
1444033838802 addons.manager DEBUG Registering shutdown blocker for PluginP
rovider
1444033838803 addons.manager DEBUG Provider finished startup: PluginProvide
r
1444033838803 addons.manager DEBUG Completed startup sequence
1444033840197 addons.manager DEBUG Starting provider: <unnamed-provider>
1444033840197 addons.manager DEBUG Registering shutdown blocker for <unname
d-provider>
1444033840198 addons.manager DEBUG Provider finished startup: <unnamed-prov
ider>
1444033841030 DeferredSave.extensions.json DEBUG Starting write
1444033841636 addons.repository DEBUG No addons.json found.
1444033841637 DeferredSave.addons.json DEBUG Save changes
1444033841642 DeferredSave.addons.json DEBUG Starting timer
1444033841680 addons.manager DEBUG Starting provider: PreviousExperimentPro
vider
1444033841680 addons.manager DEBUG Registering shutdown blocker for Previou
sExperimentProvider
1444033841681 addons.manager DEBUG Provider finished startup: PreviousExper
imentProvider
1444033841705 DeferredSave.extensions.json DEBUG Write succeeded
1444033841706 addons.xpi-utils DEBUG XPI Database saved, setting sche
ma version preference to 17
1444033841707 DeferredSave.addons.json DEBUG Starting write
1444033841764 DeferredSave.addons.json DEBUG Write succeeded
JavaScript error: file:///C:/Users/%E5%B6%BA%E5%90%BE/AppData/Local/Temp/anonymo
us3133745447996684817webdriver-profile/extensions/fxdriver@googlecode.com/compon
ents/bad-cert-listener.js, line 2245: NS_ERROR_FAILURE: Component returned failu
re code: 0x80004005 (NS_ERROR_FAILURE) [nsILocalFile.createUnique]
JavaScript error: chrome://fxdriver/content/server.js, line 61: NS_ERROR_XPC_CI_
RETURNED_FAILURE: Component returned failure code: 0x80570015 (NS_ERROR_XPC_CI_R
ETURNED_FAILURE) [nsIJSCID.createInstance]
1444033854172 addons.manager DEBUG shutdown
1444033854173 addons.manager DEBUG Calling shutdown blocker for XPIProvider
1444033854173 addons.xpi DEBUG shutdown
1444033854174 addons.xpi-utils DEBUG shutdown
1444033854175 addons.manager DEBUG Calling shutdown blocker for Lightweight
ThemeManager
1444033854176 addons.manager DEBUG Calling shutdown blocker for GMPProvider
1444033854179 addons.manager DEBUG Calling shutdown blocker for PluginProvi
der
1444033854180 addons.manager DEBUG Calling shutdown blocker for <unnamed-pr
ovider>
1444033854183 addons.manager DEBUG Calling shutdown blocker for PreviousExp
erimentProvider
1444033854190 addons.xpi DEBUG Notifying XPI shutdown observers
1444033854198 addons.manager DEBUG Async provider shutdown done
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.st
art(NewProfileExtensionConnection.java:122)
... 45 more
答案 0 :(得分:0)
您使用('2.47.1')的Selenium Webdriver版本与Firefox版本(“41.0.1”)之间的兼容性问题。我遇到过与之前版本的Webdriver相同的问题,当时降级Firefox版本有所帮助。请查看changelog以获取Selenium Webdriver或使用here中的CHANGELOG链接并使用受支持的Firefox版本。
答案 1 :(得分:0)
这是一个非常常见的问题,初学者不必担心,更好地导入最后一个selenium API,即2.47.1或者如果你使用旧版本的selenium API尝试使用 Mozilla较低版本像Mozilla 31版。我保证它会起作用。