简体   繁体   English

为Selenium Webdriver创建的第二个Java项目不调用firefox浏览器

[英]The second java project created for Selenium webdriver dont invoke the firefox browser

This is strange: I had one java project "A" in eclipse, where I created a automation framework using selenium webdriver 3.8. 这很奇怪:我在eclipse中有一个Java项目“ A”,在这里我使用selenium webdriver 3.8创建了一个自动化框架。 The test cases run without any issues on firefox & chrome. 测试用例在Firefox和chrome上运行没有任何问题。

I created another project "B" in eclipse where even a simple webdriver program to invoke a firefox browser and launching https://google.com don't work. 我在eclipse中创建了另一个项目“ B”,即使使用简单的webdriver程序来调用firefox浏览器并启动https://google.com也不起作用。 If I copy and run this java program to project "A", there it works fine. 如果我将这个Java程序复制并运行到项目“ A”,则可以正常工作。

I get following error in project B: 我在项目B中收到以下错误:

1519377466493   geckodriver INFO    geckodriver 0.19.1
1519377466501   geckodriver INFO    Listening on 127.0.0.1:23459
Feb 23, 2018 2:47:46 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
1519377467110   mozrunner::runner   INFO    Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile" "C:\\Users\\ag1\\AppData\\Local\\Temp\\rust_mozprofile.zR3DSF0kPKPE"
1519377469383   addons.xpi  WARN    Error parsing extensions state: [Exception... "Component returned failure code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [amIAddonManagerStartup.readStartupData]"  nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)"  location: "JS frame :: resource://gre/modules/addons/XPIProvider.jsm :: loadExtensionState :: line 1554"  data: no] Stack trace: loadExtensionState()@resource://gre/modules/addons/XPIProvider.jsm:1554 < getInstallState()@resource://gre/modules/addons/XPIProvider.jsm:1589 < checkForChanges()@resource://gre/modules/addons/XPIProvider.jsm:3109 < startup()@resource://gre/modules/addons/XPIProvider.jsm:2188 < callProvider()@resource://gre/modules/AddonManager.jsm:269 < _startProvider()@resource://gre/modules/AddonManager.jsm:739 < startup()@resource://gre/modules/AddonManager.jsm:906 < startup()@resource://gre/modules/AddonManager.jsm:3090 < observe()@jar:file:///C:/Program%20Files/Mozilla%20Firefox/omni.ja!/components/addonManager.js:65
1519377470745   Marionette  INFO    Enabled via --marionette
1519377478197   Marionette  INFO    Listening on port 62067
1519377478784   Marionette  DEBUG   Register listener.js for window 4294967297
Feb 23, 2018 2:47:58 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.
Feb 23, 2018 2:47:58 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to straight W3C remote end connection
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions@a38d7a3, browserName=firefox, moz:firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions@a38d7a3, version=, platform=ANY}], required capabilities = Capabilities [{}]
Build info: version: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700'
System info: host: 'EABYYA5G3S', ip: '16.166.226.122', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_161'
Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:259)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:247)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:242)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:238)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:127)
    at pilot.Firefoxtest.main(Firefoxtest.java:11)

The error says it all : 错误说明了一切:

Feb 23, 2018 2:47:46 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
.
Feb 23, 2018 2:47:58 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.
Feb 23, 2018 2:47:58 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to straight W3C remote end connection
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions@a38d7a3, browserName=firefox, moz:firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions@a38d7a3, version=, platform=ANY}], required capabilities = Capabilities [{}]
Build info: version: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700'
System info: host: 'EABYYA5G3S', ip: '16.166.226.122', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_161'
Driver info: driver.version: FirefoxDriver

The following points are clear from the error stack trace : 错误堆栈跟踪中的以下几点很清楚:

  • org.openqa.selenium.remote.ProtocolHandshake createSession wasn't successful. org.openqa.selenium.remote.ProtocolHandshake createSession不成功。 Hence falls back to OSS JSON Wire Protocol . 因此退回到OSS JSON Wire Protocol
  • Falling back to original OSS JSON Wire Protocol fails too. 后退到原始OSS JSON Wire Protocol也失败。 Hence again attempts to fall back on W3C remote end connection . 因此,再次尝试依靠W3C远程终端连接
  • org.openqa.selenium.SessionNotCreatedException is raised due to blank required capabilities 由于所需的空白功能引发org.openqa.selenium.SessionNotCreatedException

     required capabilities = Capabilities [{}] 
  • Selenium version is not detected. 未检测到版本。 (as Build info: version: 'unknown' ) (作为Build info: version: 'unknown'

  • GeckoDriver not getting detecting back. GeckoDriver无法检测回来。 (as Driver info: driver.version: FirefoxDriver ) (作为Driver info: driver.version: FirefoxDriver

Solution

The Project Space of Project B clearly appears to be error-prone due to indefinite/unknown reasons. 由于不确定/未知的原因, B 项目的项目空间显然容易出错 It will be a better option to delete the entire Project Space and create a new Project Space to resume Testing . 最好删除整个项目空间并创建一个新的项目空间以恢复测试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM