Selenium 3.3.1 StandAlone Jar

时间:2017-03-14 07:16:59

标签: java selenium selenium-firefoxdriver

我尝试使用selenium-standalone-3.3.1.jar将页面加载到Firefox 52中。但是我抛出了这个错误: -

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host  127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
":["Mozilla Contributors"]},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"C:\\Program Files\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","installDate":1488491056000,"updateDate":1488491056000,"applyBackgroundUpdates":1,"skinnable":true,"size":19581,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"52.0","maxVersion":"52.0"}],"targetPlatforms":[],"seen":true,"dependencies":[],"hasEmbeddedWebExtension":false}
1489475216110   addons.xpi  DEBUG   getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1489475216111   DeferredSave.extensions.json    DEBUG   Save changes
1489475216111   addons.xpi  DEBUG   Updating database with changes to installed add-ons
1489475216111   addons.xpi-utils    DEBUG   Updating add-on states
1489475216116   addons.xpi-utils    DEBUG   Writing add-ons list
1489475216122   addons.xpi  DEBUG   Registering manifest for C:\Program Files\Mozilla Firefox\browser\features\aushelper@mozilla.org.xpi
1489475216122   addons.xpi  DEBUG   Calling bootstrap method startup on aushelper@mozilla.org version 2.0
1489475216123   addons.xpi  DEBUG   Registering manifest for C:\Program Files\Mozilla Firefox\browser\features\e10srollout@mozilla.org.xpi
1489475216124   addons.xpi  DEBUG   Calling bootstrap method startup on e10srollout@mozilla.org version 1.9
1489475216124   addons.xpi  DEBUG   Registering manifest for C:\Program Files\Mozilla Firefox\browser\features\firefox@getpocket.com.xpi
1489475216125   addons.xpi  DEBUG   Calling bootstrap method startup on firefox@getpocket.com version 1.0.5 
1489475216125   addons.xpi  DEBUG   Registering manifest for C:\Program Files\Mozilla Firefox\browser\features\webcompat@mozilla.org.xpi
1489475216126   addons.xpi  DEBUG   Calling bootstrap method startup on webcompat@mozilla.org version 1.0
1489475216128   addons.manager  DEBUG   Registering shutdown blocker for XPIProvider
1489475216128   addons.manager  DEBUG   Provider finished startup: XPIProvider
1489475216128   addons.manager  DEBUG   Starting provider: LightweightThemeManager
1489475216128   addons.manager  DEBUG   Registering shutdown blocker for LightweightThemeManager
1489475216128   addons.manager  DEBUG   Provider finished startup: LightweightThemeManager

....
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:112)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:119)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:218)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:129)
at com.obp.selenium.Framework.WebBrowserAction.launchBrowser(WebBrowserAction.java:124)

我调用的函数如下所示,以启动Firefox WebBrowser: -

System.setProperty("webdriver.firefox.marionette",
                               aProperties.getProperties().getProperty(aProperties.getOsName() + ".BasePath")
                                                               + aProperties.getProperties().getProperty(aProperties.getOsName() + ".geckoDriverPath"));
            System.setProperty("webdriver.firefox.bin", aProperties.getProperties().getProperty(aProperties.getOsName() + ".FFbrowserPath"));
            System.setProperty("webdriver.firefox.port", String.valueOf(portNumber));
            DesiredCapabilities cap = DesiredCapabilities.firefox();
            cap.setCapability("applicationCacheEnabled", true);
            driver = new FirefoxDriver(cap);

1 个答案:

答案 0 :(得分:1)

selenium-standalone jar用于在网格中运行测试,意思是RemoteWebDriver。您正尝试在本地运行WebDriver

所以你需要先了解你需要什么?

  • 如果您想在本地运行,可以使用现在使用的相同代码,而不需要独立的jar。
  • 如果您需要在远程计算机上运行,​​则需要use the jar to setup a server and a node with Firefox并更改代码以使用RemoteWebDriver运行。 类似的东西:

driver = new RemoteWebDriver(new URL("http://HUB_URL:4444/wd/hub"), capabilities);