java应用程序使用selenium web驱动程序导入jars文件

时间:2016-04-22 04:27:09

标签: java selenium

当我使用selenium web驱动程序jars文件运行java应用程序时。我在控制台中遇到以下错误 任何人都可以为此提供解决方案吗?

 org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
    false,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"26.0","maxVersion":"47.*"}],"targetPlatforms":[],"multiprocessCompatible":false,"signedState":2,"seen":true}
    1461298595367   DeferredSave.extensions.json    DEBUG   Save changes
    1461298595367   addons.xpi  DEBUG   Updating database with changes to installed add-ons
    1461298595367   addons.xpi-utils    DEBUG   Updating add-on states
    1461298595369   addons.xpi-utils    DEBUG   Writing add-ons list
    1461298595374   addons.xpi  DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\loop@mozilla.org.xpi
    1461298595376   addons.xpi  DEBUG   Calling bootstrap method startup on loop@mozilla.org version 1.1.14
    1461298595392   addons.manager  DEBUG   Starting provider: <unnamed-provider>
    1461298595392   addons.manager  DEBUG   Registering shutdown blocker for <unnamed-provider>
    1461298595392   addons.manager  DEBUG   Provider finished startup: <unnamed-provider>
    1461298595408   addons.xpi  DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\extensions\{82AF8DCA-6DE9-405D-BD5E-43525BDAD38A}.xpi
    1461298595408   addons.xpi  DEBUG   Calling bootstrap method startup on {82AF8DCA-6DE9-405D-BD5E-43525BDAD38A} version 8.0.0.9103
    1461298595476   addons.manager  DEBUG   Registering shutdown blocker for XPIProvider
    1461298595476   addons.manager  DEBUG   Provider finished startup: XPIProvider
    1461298595476   addons.manager  DEBUG   Starting provider: LightweightThemeManager
    1461298595476   addons.manager  DEBUG   Registering shutdown blocker for LightweightThemeManager
    1461298595476   addons.manager  DEBUG   Provider finished startup: LightweightThemeManager
    1461298595477   addons.manager  DEBUG   Starting provider: GMPProvider
    1461298595485   addons.manager  DEBUG   Registering shutdown blocker for GMPProvider
    1461298595486   addons.manager  DEBUG   Provider finished startup: GMPProvider
    1461298595486   addons.manager  DEBUG   Starting provider: PluginProvider
    1461298595486   addons.manager  DEBUG   Registering shutdown blocker for PluginProvider
    1461298595487   addons.manager  DEBUG   Provider finished startup: PluginProvider
    1461298595488   addons.manager  DEBUG   Completed startup sequence
    1461298596837   DeferredSave.extensions.json    DEBUG   Write succeeded
    1461298596837   addons.xpi-utils    DEBUG   XPI Database saved, setting schema version preference to 17
    1461298596837   DeferredSave.extensions.json    DEBUG   Starting timer
    1461298596850   addons.repository   DEBUG   No addons.json found.
    1461298596851   DeferredSave.addons.json    DEBUG   Save changes
    1461298596855   DeferredSave.addons.json    DEBUG   Starting timer
    1461298596928   addons.manager  DEBUG   Starting provider: PreviousExperimentProvider
    1461298596928   addons.manager  DEBUG   Registering shutdown blocker for PreviousExperimentProvider
    1461298596929   addons.manager  DEBUG   Provider finished startup: PreviousExperimentProvider
    1461298596937   DeferredSave.extensions.json    DEBUG   Starting write
    1461298596937   DeferredSave.addons.json    DEBUG   Starting write
    1461298597024   DeferredSave.extensions.json    DEBUG   Write succeeded
    1461298597029   DeferredSave.addons.json    DEBUG   Write succeeded
    1461298603744   addons.xpi  DEBUG   Calling bootstrap method shutdown on loop@mozilla.org version 1.1.14
    1461298603749   addons.xpi  DEBUG   Calling bootstrap method shutdown on {82AF8DCA-6DE9-405D-BD5E-43525BDAD38A} version 8.0.0.9103
    1461298604018   addons.manager  DEBUG   shutdown
    1461298604018   addons.manager  DEBUG   Calling shutdown blocker for <unnamed-provider>
    1461298604018   addons.manager  DEBUG   Calling shutdown blocker for XPIProvider
    1461298604019   addons.xpi  DEBUG   shutdown
    1461298604019   addons.xpi-utils    DEBUG   shutdown
    1461298604019   addons.manager  DEBUG   Calling shutdown blocker for LightweightThemeManager
    1461298604020   addons.manager  DEBUG   Calling shutdown blocker for GMPProvider
    1461298604021   addons.manager  DEBUG   Calling shutdown blocker for PluginProvider
    1461298604023   addons.manager  DEBUG   Calling shutdown blocker for PreviousExperimentProvider
    1461298604025   addons.xpi  DEBUG   Notifying XPI shutdown observers
    1461298604031   addons.manager  DEBUG   Async provider shutdown done

        at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:122)
        at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:117)
        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:207)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
        at mySecondProgram.SeleniumFirstProject.main(SeleniumFirstProject.java:13)
    Exception in thread "main" org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(C:\Program Files (x86)\Mozilla Firefox\firefox.exe) on port 7055; process output follows: 
    false,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"26.0","maxVersion":"47.*"}],"targetPlatforms":[],"multiprocessCompatible":false,"signedState":2,"seen":true}
    1461298595367   DeferredSave.extensions.json    DEBUG   Save changes
    1461298595367   addons.xpi  DEBUG   Updating database with changes to installed add-ons
    1461298595367   addons.xpi-utils    DEBUG   Updating add-on states
    1461298595369   addons.xpi-utils    DEBUG   Writing add-ons list
    1461298595374   addons.xpi  DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\loop@mozilla.org.xpi
    1461298595376   addons.xpi  DEBUG   Calling bootstrap method startup on loop@mozilla.org version 1.1.14
    1461298595392   addons.manager  DEBUG   Starting provider: <unnamed-provider>
    1461298595392   addons.manager  DEBUG   Registering shutdown blocker for <unnamed-provider>
    1461298595392   addons.manager  DEBUG   Provider finished startup: <unnamed-provider>
    1461298595408   addons.xpi  DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\extensions\{82AF8DCA-6DE9-405D-BD5E-43525BDAD38A}.xpi
    1461298595408   addons.xpi  DEBUG   Calling bootstrap method startup on {82AF8DCA-6DE9-405D-BD5E-43525BDAD38A} version 8.0.0.9103
    1461298595476   addons.manager  DEBUG   Registering shutdown blocker for XPIProvider
    1461298595476   addons.manager  DEBUG   Provider finished startup: XPIProvider
    1461298595476   addons.manager  DEBUG   Starting provider: LightweightThemeManager
    1461298595476   addons.manager  DEBUG   Registering shutdown blocker for LightweightThemeManager
    1461298595476   addons.manager  DEBUG   Provider finished startup: LightweightThemeManager
    1461298595477   addons.manager  DEBUG   Starting provider: GMPProvider
    1461298595485   addons.manager  DEBUG   Registering shutdown blocker for GMPProvider
    1461298595486   addons.manager  DEBUG   Provider finished startup: GMPProvider
    1461298595486   addons.manager  DEBUG   Starting provider: PluginProvider
    1461298595486   addons.manager  DEBUG   Registering shutdown blocker for PluginProvider
    1461298595487   addons.manager  DEBUG   Provider finished startup: PluginProvider
    1461298595488   addons.manager  DEBUG   Completed startup sequence
    1461298596837   DeferredSave.extensions.json    DEBUG   Write succeeded
    1461298596837   addons.xpi-utils    DEBUG   XPI Database saved, setting schema version preference to 17
    1461298596837   DeferredSave.extensions.json    DEBUG   Starting timer
    1461298596850   addons.repository   DEBUG   No addons.json found.
    1461298596851   DeferredSave.addons.json    DEBUG   Save changes
    1461298596855   DeferredSave.addons.json    DEBUG   Starting timer
    1461298596928   addons.manager  DEBUG   Starting provider: PreviousExperimentProvider
    1461298596928   addons.manager  DEBUG   Registering shutdown blocker for PreviousExperimentProvider
    1461298596929   addons.manager  DEBUG   Provider finished startup: PreviousExperimentProvider
    1461298596937   DeferredSave.extensions.json    DEBUG   Starting write
    1461298596937   DeferredSave.addons.json    DEBUG   Starting write
    1461298597024   DeferredSave.extensions.json    DEBUG   Write succeeded
    1461298597029   DeferredSave.addons.json    DEBUG   Write succeeded
    1461298603744   addons.xpi  DEBUG   Calling bootstrap method shutdown on loop@mozilla.org version 1.1.14
    1461298603749   addons.xpi  DEBUG   Calling bootstrap method shutdown on {82AF8DCA-6DE9-405D-BD5E-43525BDAD38A} version 8.0.0.9103
    1461298604018   addons.manager  DEBUG   shutdown
    1461298604018   addons.manager  DEBUG   Calling shutdown blocker for <unnamed-provider>
    1461298604018   addons.manager  DEBUG   Calling shutdown blocker for XPIProvider
    1461298604019   addons.xpi  DEBUG   shutdown
    1461298604019   addons.xpi-utils    DEBUG   shutdown
    1461298604019   addons.manager  DEBUG   Calling shutdown blocker for LightweightThemeManager
    1461298604020   addons.manager  DEBUG   Calling shutdown blocker for GMPProvider
    1461298604021   addons.manager  DEBUG   Calling shutdown blocker for PluginProvider
    1461298604023   addons.manager  DEBUG   Calling shutdown blocker for PreviousExperimentProvider
    1461298604025   addons.xpi  DEBUG   Notifying XPI shutdown observers
    1461298604031   addons.manager  DEBUG   Async provider shutdown done

    Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'
    System info: host: 'DESKTOP-CH3D0C4', ip: '192.168.0.6', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_71'
    Driver info: driver.version: FirefoxDriver
        at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:134)
        at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:117)
        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:207)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
        at mySecondProgram.SeleniumFirstProject.main(SeleniumFirstProject.java:13)
    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:
    false,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"26.0","maxVersion":"47.*"}],"targetPlatforms":[],"multiprocessCompatible":false,"signedState":2,"seen":true}
    1461298595367   DeferredSave.extensions.json    DEBUG   Save changes
    1461298595367   addons.xpi  DEBUG   Updating database with changes to installed add-ons
    1461298595367   addons.xpi-utils    DEBUG   Updating add-on states
    1461298595369   addons.xpi-utils    DEBUG   Writing add-ons list
    1461298595374   addons.xpi  DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\loop@mozilla.org.xpi
    1461298595376   addons.xpi  DEBUG   Calling bootstrap method startup on loop@mozilla.org version 1.1.14
    1461298595392   addons.manager  DEBUG   Starting provider: <unnamed-provider>
    1461298595392   addons.manager  DEBUG   Registering shutdown blocker for <unnamed-provider>
    1461298595392   addons.manager  DEBUG   Provider finished startup: <unnamed-provider>
    1461298595408   addons.xpi  DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\extensions\{82AF8DCA-6DE9-405D-BD5E-43525BDAD38A}.xpi
    1461298595408   addons.xpi  DEBUG   Calling bootstrap method startup on {82AF8DCA-6DE9-405D-BD5E-43525BDAD38A} version 8.0.0.9103
    1461298595476   addons.manager  DEBUG   Registering shutdown blocker for XPIProvider
    1461298595476   addons.manager  DEBUG   Provider finished startup: XPIProvider
    1461298595476   addons.manager  DEBUG   Starting provider: LightweightThemeManager
    1461298595476   addons.manager  DEBUG   Registering shutdown blocker for LightweightThemeManager
    1461298595476   addons.manager  DEBUG   Provider finished startup: LightweightThemeManager
    1461298595477   addons.manager  DEBUG   Starting provider: GMPProvider
    1461298595485   addons.manager  DEBUG   Registering shutdown blocker for GMPProvider
    1461298595486   addons.manager  DEBUG   Provider finished startup: GMPProvider
    1461298595486   addons.manager  DEBUG   Starting provider: PluginProvider
    1461298595486   addons.manager  DEBUG   Registering shutdown blocker for PluginProvider
    1461298595487   addons.manager  DEBUG   Provider finished startup: PluginProvider
    1461298595488   addons.manager  DEBUG   Completed startup sequence
    1461298596837   DeferredSave.extensions.json    DEBUG   Write succeeded
    1461298596837   addons.xpi-utils    DEBUG   XPI Database saved, setting schema version preference to 17
    1461298596837   DeferredSave.extensions.json    DEBUG   Starting timer
    1461298596850   addons.repository   DEBUG   No addons.json found.
    1461298596851   DeferredSave.addons.json    DEBUG   Save changes
    1461298596855   DeferredSave.addons.json    DEBUG   Starting timer
    1461298596928   addons.manager  DEBUG   Starting provider: PreviousExperimentProvider
    1461298596928   addons.manager  DEBUG   Registering shutdown blocker for PreviousExperimentProvider
    1461298596929   addons.manager  DEBUG   Provider finished startup: PreviousExperimentProvider
    1461298596937   DeferredSave.extensions.json    DEBUG   Starting write
    1461298596937   DeferredSave.addons.json    DEBUG   Starting write
    1461298597024   DeferredSave.extensions.json    DEBUG   Write succeeded
    1461298597029   DeferredSave.addons.json    DEBUG   Write succeeded
    1461298603744   addons.xpi  DEBUG   Calling bootstrap method shutdown on loop@mozilla.org version 1.1.14
    1461298603749   addons.xpi  DEBUG   Calling bootstrap method shutdown on {82AF8DCA-6DE9-405D-BD5E-43525BDAD38A} version 8.0.0.9103
    1461298604018   addons.manager  DEBUG   shutdown
    1461298604018   addons.manager  DEBUG   Calling shutdown blocker for <unnamed-provider>
    1461298604018   addons.manager  DEBUG   Calling shutdown blocker for XPIProvider
    1461298604019   addons.xpi  DEBUG   shutdown
    1461298604019   addons.xpi-utils    DEBUG   shutdown
    1461298604019   addons.manager  DEBUG   Calling shutdown blocker for LightweightThemeManager
    1461298604020   addons.manager  DEBUG   Calling shutdown blocker for GMPProvider
    1461298604021   addons.manager  DEBUG   Calling shutdown blocker for PluginProvider
    1461298604023   addons.manager  DEBUG   Calling shutdown blocker for PreviousExperimentProvider
    1461298604025   addons.xpi  DEBUG   Notifying XPI shutdown observers
    1461298604031   addons.manager  DEBUG   Async provider shutdown done

        at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:122)
        ... 7 more

2 个答案:

答案 0 :(得分:0)

可能有两个问题

  1. Fire Fox Path错误地修复了对firefox.exe的重新检查路径 通过指定FF的路径
  2. 来尝试这个

    WebDriver driver = new FirefoxDriver(new FirefoxBinary(new file(“path / to / your / firefox.exe”)),profile);

    1. 使用的二进制文件与您的Fire Fox版本不兼容。
    2. 要解决此问题,请访问selenium网站,并确保您的浏览器兼容版本 Selenium Change Log

答案 1 :(得分:0)

这是因为firefox的最新浏览器中出现了新问题。

更新您的硒罐。新版本的firefox(或不同的浏览器)不支持旧版的selenium。

下载Selenium Server(以前的Selenium RC Server)Selenium Client&amp; WebDriver语言绑定

用您正在使用的旧罐子替换它们。同时更新您的mozilla,以便获得更新的结果

来源: - http://docs.seleniumhq.org/download/

要解决此问题,您还需要将setPreference设置为xpinstall.signatures.required", false到firefox配置文件,然后将其传递给驱动程序对象

firefoxProfile.setPreference("xpinstall.signatures.required", false);

下面的代码对我来说很好。

static WebDriver driver=null;
public static void main(String[] args) {
final FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("xpinstall.signatures.required", false);
driver = new FirefoxDriver(firefoxProfile);
driver.get("https://www.google.de/");

希望它会对你有所帮助:)。