微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java-Firefox浏览器未加载并显示错误:typeError:addon为null

public class firstTest {

    public static void main(String[] args) {

        System.setProperty("webdriver.gecko.driver", "E:\\SOFTWARE\\drivers\\geckodriver.exe");
        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.google.com");
    }
}

执行上述代码时,出现以下错误

Unable to read VR Path Registry from C:\Users\DEEPAK D P\AppData\Local\openvr\openvrpaths.vrpath
JavaScript error: resource://gre/modules/addons/XPIProvider.jsm, line 3345: TypeError: addon is null
1521607690370   addons.productaddons    INFO    sending request to: https://aus5.mozilla.org/update/3/GMP/59.0.1/20180315233128/WINNT_x86_64-msvc-x64/en-GB/release/Windows_NT%2010.0.0.0.16299.125%20(x64)/default/default/update.xml
1521607691520   addons.productaddons    INFO    Completed downloading document
1521607692630   addons.productaddons    INFO    downloadXHR File download. status=200
1521607692638   addons.productaddons    INFO    Downloaded file will be saved to C:\Users\DEEPAK~1\AppData\Local\Temp\tmpaddon-c492c1
1521607698968   addons.productaddons    INFO    downloadXHR File download. status=200
1521607698976   addons.productaddons    INFO    Downloaded file will be saved to C:\Users\DEEPAK~1\AppData\Local\Temp\tmpaddon-47ef79

    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 tests.firstTest.main(firstTest.java:22)
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: 
[email protected]
1521607670798   addons.xpi  DEBUG   Ignoring file entry whose name is not a valid add-on ID: C:\Users\xxx \AppData\Local\Temp\anonymous4306519380516409248webdriver-profile\extensions\webdriver-staging
1521607670798   addons.xpi  DEBUG   Existing add-on [email protected] in app-profile
1521607670800   addons.xpi  INFO    Mapping [email protected] to C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1521607670800   addons.xpi  INFO    Mapping [email protected] to C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1521607670800   addons.xpi  INFO    Mapping [email protected] to C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1521607670800   addons.xpi  INFO    Mapping [email protected] to C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1521607670800   addons.xpi  INFO    Mapping [email protected] to C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1521607670800   addons.xpi  INFO    Mapping [email protected] to C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1521607670800   addons.xpi  INFO    Mapping [email protected] to C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1521607670800   addons.xpi  INFO    Mapping [email protected] to C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1521607670800   addons.xpi  INFO    Mapping [email protected] to C:\Program Files (x86)\Mozilla Firefox\browser\features\[email protected]
1521607670802   addons.xpi  DEBUG   Existing add-on [email protected] in app-system-defaults
1521607670802   addons.xpi  DEBUG   Existing add-on [email protected] in app-system-defaults
1521607670802   addons.xpi  DEBUG   Existing add-on [email protected] in app-system-defaults
1521607670802   addons.xpi  DEBUG   Existing add-on [email protected] in app-system-defaults
1521607670802   addons.xpi  DEBUG   Existing add-on [email protected] in app-system-defaults
1521607670804   addons.xpi  DEBUG   Existing add-on [email protected] in app-system-defaults
1521607670804   addons.xpi  DEBUG   Existing add-on [email protected] in app-system-defaults
1521607670804   addons.xpi  DEBUG   Existing add-on [email protected] in app-system-defaults
1521607670804   addons.xpi  DEBUG   Existing add-on [email protected] in app-system-defaults
1521607670806   addons.xpi  INFO    Mapping {82AF8DCA-6DE9-405D-BD5E-43525BDAD38A} to C:\Program Files (x86)\Mozilla Firefox\browser\extensions\{82AF8DCA-6DE9-405D-BD5E-43525BDAD38A}.xpi
1521607670806   addons.xpi  INFO    Mapping {972ce4c6-7e08-4474-a285-3208198ce6fd} to C:\Program Files (x86)\Mozilla Firefox\browser\extensions\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi
1521607670806   addons.xpi  DEBUG   Existing add-on {82AF8DCA-6DE9-405D-BD5E-43525BDAD38A} in app-global
1521607670806   addons.xpi  DEBUG   Existing add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} in app-global
1521607670806   addons.xpi  DEBUG   getInstallState changed: false, state: {}
Unable to read VR Path Registry from C:\Users\DEEPAK D P\AppData\Local\openvr\openvrpaths.vrpath
JavaScript error: resource://gre/modules/addons/XPIProvider.jsm, line 3345: TypeError: addon is null
1521607690370   addons.productaddons    INFO    sending request to: https://aus5.mozilla.org/update/3/GMP/59.0.1/20180315233128/WINNT_x86_64-msvc-x64/en-GB/release/Windows_NT%2010.0.0.0.16299.125%20(x64)/default/default/update.xml
1521607691520   addons.productaddons    INFO    Completed downloading document
1521607692630   addons.productaddons    INFO    downloadXHR File download. status=200
1521607692638   addons.productaddons    INFO    Downloaded file will be saved to C:\Users\DEEPAK~1\AppData\Local\Temp\tmpaddon-c492c1
1521607698968   addons.productaddons    INFO    downloadXHR File download. status=200
1521607698976   addons.productaddons    INFO    Downloaded file will be saved to C:\Users\DEEPAK~1\AppData\Local\Temp\tmpaddon-47ef79

Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:59:12'
System info: host: 'xxx', ip: '192.168.43.34', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_40'
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 tests.firstTest.main(firstTest.java:22)
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:
[email protected]
1521607670798   addons.xpi  DEBUG   Ignoring file entry whose name is not a valid add-on ID: C:\Users\DEEPAK D P\AppData\Local\Temp\anonymous4306519380516409248webdriver-profile\extensions\webdriver-staging
1521607670798   addons.xpi  DEBUG   Existing add-on [email protected] in app-profile

解决方法:

错误说明了一切:

Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:59:12'
System info: host: 'xxx', ip: '192.168.43.34', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_40'
Driver info: driver.version: FirefoxDriver

错误跟踪日志明确提到浏览器客户端无法识别回FirefoxDriver二进制文件.

您的主要问题是所使用的二进制文件间的版本兼容性,如下所示:

>您的Selenium Client版本是2015年10月9日19:59:12的2.48.2,比旧版本快2.5年.
>您的JDK版本是1.8.0_40,这非常古老.
>我们不知道您的GeckoDriver版本.
>我们不知道您的Firefox版本.

因此,JDK v8u40和Selenium Client v2.48.2之间显然不匹配.

>将JDK升级到最新级别JDK 8u162.
>将硒升级到当前水平Version 3.11.0.
>将GeckoDriver升级GeckoDriver v0.20.0级别.
>将Firefox版本升级到Firefox v59.0.1级别.
>通过IDE清理项目工作区,并仅使用必需的依赖项重建项目.
>使用CCleaner工具清除测试套件执行前后的所有操作系统杂项.
>如果您的基本Firefox基本版本太旧,请通过Revo Uninstaller卸载它,并安装最新的GA和发行版本的Firefox.
>执行您的@Test.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐