Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
768 views
in Technique[技术] by (71.8m points)

selenium - UnreachableBrowserException Caused by: java.lang.NullPointerException when "webdriver.firefox.marionette" is used

I'm using Selenium 3.4.0, Java 1.8 and Firefox 54.0.1(64 bit). I'm getting a null pointer exception when I try to open a link with Firefox. When I use Selenium/Python it works fine, but I'm trying to run the code from this guru 99 page (https://www.guru99.com/first-webdriver-script.html).I've searched to see if anyone else has had this problem, but I can't find any solutions. I get the following output:

1501246654252   addons.manager  DEBUG   Application has been upgraded
1501246654291   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/addons/XPIProvider.jsm: ["XPIProvider"]
1501246654293   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/LightweightThemeManager.jsm: ["LightweightThemeManager"]
1501246654297   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/addons/GMPProvider.jsm
1501246654299   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/addons/PluginProvider.jsm
1501246654299   addons.manager  DEBUG   Starting provider: XPIProvider
1501246654300   addons.xpi  DEBUG   startup
1501246654301   addons.xpi  INFO    Mapping fxdriver@googlecode.com to C:UsersCHRISG~1AppDataLocalTempanonymous8191426632770324153webdriver-profileextensionsfxdriver@googlecode.com
1501246654301   addons.xpi  DEBUG   Ignoring file entry whose name is not a valid add-on ID: C:UsersCHRISG~1AppDataLocalTempanonymous8191426632770324153webdriver-profileextensionswebdriver-staging
1501246654301   addons.xpi  INFO    Removing all system add-on upgrades.
1501246654301   addons.xpi  INFO    SystemAddonInstallLocation directory is missing
1501246654302   addons.xpi  INFO    Mapping aushelper@mozilla.org to C:Program FilesMozilla Firefoxrowserfeaturesaushelper@mozilla.org.xpi
1501246654303   addons.xpi  INFO    Mapping e10srollout@mozilla.org to C:Program FilesMozilla Firefoxrowserfeaturese10srollout@mozilla.org.xpi
1501246654303   addons.xpi  INFO    Mapping firefox@getpocket.com to C:Program FilesMozilla Firefoxrowserfeaturesfirefox@getpocket.com.xpi
1501246654303   addons.xpi  INFO    Mapping screenshots@mozilla.org to C:Program FilesMozilla Firefoxrowserfeaturesscreenshots@mozilla.org.xpi
1501246654304   addons.xpi  INFO    Mapping webcompat@mozilla.org to C:Program FilesMozilla Firefoxrowserfeatureswebcompat@mozilla.org.xpi
1501246654305   addons.xpi  INFO    Mapping {972ce4c6-7e08-4474-a285-3208198ce6fd} to C:Program FilesMozilla Firefoxrowserextensions{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi
1501246654305   addons.xpi  DEBUG   Skipping unavailable install location app-system-share
1501246654305   addons.xpi  DEBUG   Skipping unavailable install location app-system-local
1501246654306   addons.xpi  DEBUG   checkForChanges
1501246654306   addons.xpi  INFO    SystemAddonInstallLocation directory is missing
1501246654307   addons.xpi  DEBUG   Loaded add-on state from prefs: {}
1501246654308   addons.xpi  DEBUG   New add-on fxdriver@googlecode.com in app-profile
1501246654308   addons.xpi  DEBUG   getModTime: Recursive scan of fxdriver@googlecode.com
1501246654313   addons.xpi  DEBUG   New add-on aushelper@mozilla.org in app-system-defaults
1501246654313   addons.xpi  DEBUG   getModTime: Recursive scan of aushelper@mozilla.org
1501246654314   addons.xpi  DEBUG   New add-on e10srollout@mozilla.org in app-system-defaults
1501246654315   addons.xpi  DEBUG   getModTime: Recursive scan of e10srollout@mozilla.org
1501246654315   addons.xpi  DEBUG   New add-on firefox@getpocket.com in app-system-defaults
1501246654315   addons.xpi  DEBUG   getModTime: Recursive scan of firefox@getpocket.com
1501246654315   addons.xpi  DEBUG   New add-on screenshots@mozilla.org in app-system-defaults
1501246654316   addons.xpi  DEBUG   getModTime: Recursive scan of screenshots@mozilla.org
1501246654316   addons.xpi  DEBUG   New add-on webcompat@mozilla.org in app-system-defaults
1501246654316   addons.xpi  DEBUG   getModTime: Recursive scan of webcompat@mozilla.org
1501246654317   addons.xpi  DEBUG   New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} in app-global
1501246654317   addons.xpi  DEBUG   getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1501246654317   addons.xpi  DEBUG   getInstallState changed: true, state: {"app-profile":{"fxdriver@googlecode.com":{"d":"C:\Users\CHRISG~1\AppData\Local\Temp\anonymous8191426632770324153webdriver-profile\extensions\fxdriver@googlecode.com","st":1501246654037,"mt":1501246653985}},"app-system-defaults":{"aushelper@mozilla.org":{"d":"C:\Program Files\Mozilla Firefox\browser\features\aushelper@mozilla.org.xpi","st":1498667065000},"e10srollout@mozilla.org":{"d":"C:\Program Files\Mozilla Firefox\browser\features\e10srollout@mozilla.org.xpi","st":1498667065000},"firefox@getpocket.com":{"d":"C:\Program Files\Mozilla Firefox\browser\features\firefox@getpocket.com.xpi","st":1498667066000},"screenshots@mozilla.org":{"d":"C:\Program Files\Mozilla Firefox\browser\features\screenshots@mozilla.org.xpi","st":1498667067000},"webcompat@mozilla.org":{"d":"C:\Program Files\Mozilla Firefox\browser\features\webcompat@mozilla.org.xpi","st":1498667066000}},"app-global":{"{972ce4c6-7e08-4474-a285-3208198ce6fd}":{"d":"C:\Program Files\Mozilla Firefox\browser\extensions\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","st":1498667065000}}}
1501246654324   addons.xpi-utils    DEBUG   Opening XPI database C:UsersCHRISG~1AppDataLocalTempanonymous8191426632770324153webdriver-profileextensions.json
1501246654326   addons.xpi-utils    DEBUG   New add-on fxdriver@googlecode.com installed in app-profile
*** Blocklist::_loadBlocklistFromFile: blocklist is disabled
1501246654340   addons.xpi  WARN    Add-on fxdriver@googlecode.com is not correctly signed.
1501246654340   addons.xpi  WARN    Add-on fxdriver@googlecode.com is not correctly signed.
1501246654343   DeferredSave.extensions.json    DEBUG   Save changes
1501246654343   addons.xpi-utils    DEBUG   New add-on aushelper@mozilla.org installed in app-system-defaults
1501246654346   DeferredSave.extensions.json    DEBUG   Starting timer
1501246654349   DeferredSave.extensions.json    DEBUG   Save changes
1501246654349   addons.xpi-utils    DEBUG   New add-on e10srollout@mozilla.org installed in app-system-defaults
1501246654354   DeferredSave.extensions.json    DEBUG   Save changes
1501246654355   addons.xpi-utils    DEBUG   New add-on firefox@getpocket.com installed in app-system-defaults
1501246654359   DeferredSave.extensions.json    DEBUG   Save changes
1501246654359   addons.xpi-utils    DEBUG   New add-on screenshots@mozilla.org installed in app-system-defaults
1501246654365   DeferredSave.extensions.json    DEBUG   Save changes
1501246654365   addons.xpi-utils    DEBUG   New add-on webcompat@mozilla.org installed in app-system-defaults
1501246654369   DeferredSave.extensions.json    DEBUG   Save changes
1501246654370   addons.xpi-utils    DEBUG   New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global
1501246654373   DeferredSave.extensions.json    DEBUG   Starting write
1501246654379   DeferredSave.extensions.json    DEBUG   Save changes
1501246654380   DeferredSave.extensions.json    DEBUG   Data changed while write in progress
1501246654380   addons.manager  DEBUG   Registering startup change 'installed' for fxdriver@googlecode.com
1501246654380   addons.xpi-utils    DEBUG   Make addon app-profile:fxdriver@googlecode.com visible
1501246654381   DeferredSave.extensions.json    DEBUG   Save changes
1501246654381   addons.manager  DEBUG   Registering startup change 'installed' for aushelper@mozilla.org
1501246654390   addons.xpi  DEBUG   Loading bootstrap scope from C:Program FilesMozilla Firefoxrowserfeaturesaushelper@mozilla.org.xpi
1501246654394   addons.xpi  DEBUG   Calling bootstrap method install on aushelper@mozilla.org version 2.0
1501246654395   addons.xpi-utils    DEBUG   Make addon app-system-defaults:aushelper@mozilla.org visible
1501246654395   DeferredSave.extensions.json    DEBUG   Save changes
1501246654395   addons.manager  DEBUG   Registering startup change 'installed' for e10srollout@mozilla.org
1501246654396   addons.xpi  DEBUG   Loading bootstrap scope from C:Program FilesMozilla Firefoxrowserfeaturese10srollout@mozilla.org.xpi
1501246654399   addons.xpi  DEBUG   Calling bootstrap method install on e10srollout@mozilla.org version 1.50
1501246654400   addons.xpi-utils    DEBUG   Make addon app-system-defaults:e10srollout@mozilla.org visible
1501246654400   DeferredSave.extensions.json    DEBUG   Save changes
1501246654400   addons.manager  DEBUG   Registering startup change 'installed' for firefox@getpocket.com
1501246654401   addons.xpi  DEBUG   Loading bootstrap scope from C:Program FilesMozilla Firefoxrowserfeaturesfirefox@getpocket.com.xpi
1501246654405   addons.xpi  DEBUG   Calling bootstrap method install on firefox@getpocket.com version 1.0.5
1501246654405   addons.xpi-utils    DEBUG   Make addon app-system-defaults:firefox@getpocket.com visible
1501246654406   DeferredSave.extensions.json    DEBUG   Save changes
1501246654406   addons.manager  DEBUG   Registering startup change 'installed' for screenshots@mozilla.org
1501246654407   addons.xpi  DEBUG   Loading bootstrap scope from C:Program FilesMozilla Firefoxrowserfeaturesscreenshots@mozilla.org.xpi
1501246654410   addons.xpi  DEBUG   Calling bootstrap method install on screenshots@mozilla.org version 6.6.0
1501246654410   addons.xpi-utils    DEBUG   Make addon app-system-defaults:screenshots@mozilla.org visible
1501246654410   DeferredSave.extensions.json    DEBUG   Save changes
1501246654410   addons.manager  DEBUG   Registering startup change 'installed' for webcompat@mozilla.org
1501246654411   addons.xpi  DEBUG   Loading bootstrap scope from C:Program FilesMozilla Firefoxrowserfeatureswebcompat@mozilla.org.xpi
1501246654413   addons.xpi  DEBUG   Calling bootstrap method install on webcompat@mozilla.org version 1.1
1501246654413   addons.xpi-utils    DEBUG   Make addon app-system-defaults:webcompat@mozilla.org visible
1501246654413   DeferredSave.extensions.json    DEBUG   Save changes
1501246654414   addons.xpi-utils    DEBUG   Make addon app-global:{972ce4c6-7e08-4474-a285-3208198ce6fd} visible
1501246654414   DeferredSave.extensions.json    DEBUG   Save changes
1501246654414   addons.xpi  DEBUG   Updating XPIState for {"id":"fxdriver@googlecode.com","syncGUID":"{284a66e3-05a6-4d03-b43d-a92a5f93e2f7}","location":"app-profile","version":"3.4.0","type":"extension","internalName":null,"updateURL":null,"updateKey":null,"optionsURL":null,"optionsType":null,"aboutURL":null,"icons":{},"iconURL":null,"icon64URL":null,"defaultLocale":{"name":"Firefox WebDriver","description":"WebDriver implementation for Firefox","creator":"Simon Stewart","homepageURL":null},"visible":true,"active":false,"userDisabled":false,"appDisabled":true,"descriptor":"C:\Users\CHRISG~1\AppData\Local\Temp\anonymous8191426632770324153webdriver-profile\extensions\fxdriver@googlecode.com","installDate":1501246654037,"updateDate":1501246654037,"applyBackgroundUpdates":1,"bootstrap":false,"skinnable":false,"size":3303362,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":true,"hasBinaryComponents":false,"strictCompatibility":false,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"3.0","maxVersion":"48.0"}],"targetPlatforms":[{"os":"Darwin","abi":null},{"os":"SunOS","abi":null},{"os":"FreeBSD","abi":null},{"os":"OpenBSD","abi":null},{"os":"WINNT","abi":null},{"os":"Linux","abi":null}],"multiprocessCompatible":false,"signedState":0,"seen":true,"dependencies":[],"hasEmbeddedWebExtension":false,"mpcOptedOut":false,"userPermissions":null}
1501246654415   addons.xpi  DEBUG   Updating XPISt

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here is the Answer to your Question:

The error UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure says it all.

As per guru99.com it is mentioned to use webdriver.firefox.marionette within System.setProperty. In Selenium 3.x we would be using webdriver.gecko.driver instead.

So consider changing the line of code:

System.setProperty("webdriver.firefox.marionette","C:\geckodriver.exe");

to:

System.setProperty("webdriver.gecko.driver","C:\your_directory\geckodriver.exe");

Let me know if this Answers your Question.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...