6

在尝试:

WebDriver driver=new FirefoxDriver();

我收到以下错误:

java.lang.NoSuchMethodError: org.openqa.selenium.Proxy.extractFrom(Lorg/openqa/selenium/Capabilities;)Lorg/openqa/selenium/Proxy;
  at org.openqa.selenium.firefox.FirefoxDriver.dropCapabilities(FirefoxDriver.java:313)
  at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:191)
  at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
  at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182)
  at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:95)

这个问题在 ubuntu 上的 firefox 更新到 32.0 版本后就开始了,我尝试安装 28.0 版本但仍然没有工作。

有任何想法吗?提前致谢

像curiosu所说的将驱动程序版本更改为 2.39 后,出现一个新错误:

 org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on       port 7055 after 45000 ms. Firefox console output:
pp-system-share:{2e1445b0-2682-11e1-bfc2-0800200c9a66} visible
1409862347400   DeferredSave.extensions.json    DEBUG   Save changes
1409862347400   DeferredSave.extensions.json    DEBUG   Save changes
1409862347405   addons.xpi  DEBUG   Updating database with changes to installed add-ons
1409862347405   addons.xpi-utils    DEBUG   Updating add-on states
1409862347406   addons.xpi-utils    DEBUG   Writing add-ons list
1409862347407   addons.xpi  DEBUG   Registering manifest for /usr/lib/firefox/browser/extensions/langpack-en-ZA@firefox.mozilla.org.xpi
1409862347408   addons.xpi  DEBUG   Registering manifest for /usr/lib/firefox/browser/extensions/langpack-en-GB@firefox.mozilla.org.xpi
1409862347408   addons.xpi  DEBUG   Registering manifest for /usr/lib/firefox/browser/extensions/langpack-ar@firefox.mozilla.org.xpi
1409862348534   DeferredSave.extensions.json    DEBUG   Starting timer
1409862348581   addons.manager  DEBUG   shutdown
1409862348587   DeferredSave.extensions.json    DEBUG   Starting write
1409862348587   addons.xpi  DEBUG   shutdown
1409862348588   addons.xpi-utils    DEBUG   shutdown
1409862348644   DeferredSave.extensions.json    DEBUG   Write succeeded
1409862348644   addons.xpi-utils    DEBUG   XPI Database saved, setting schema version preference to 16
1409862348645   addons.xpi  DEBUG   Notifying XPI shutdown observers
1409862348649   addons.manager  DEBUG   Async provider shutdown done

(process:3519): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed

(firefox:3519): GLib-GObject-WARNING **: Attempt to add property GnomeProgram::sm-connect after class was initialised

(firefox:3519): GLib-GObject-WARNING **: Attempt to add property GnomeProgram::show-crash-dialog after class was initialised

(firefox:3519): GLib-GObject-WARNING **: Attempt to add property GnomeProgram::display after class was initialised

(firefox:3519): GLib-GObject-WARNING **: Attempt to add property GnomeProgram::default-icon after class was initialised
1409862349347   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/addons/XPIProvider.jsm: ["XPIProvider"]
1409862349349   addons.manager  DEBUG   Loaded provider scope for resource://gre/modules/LightweightThemeManager.jsm: ["LightweightThemeManager"]
1409862349352   addons.xpi  DEBUG   startup
1409862349354   addons.xpi  INFO    Mapping ubufox@ubuntu.com to /usr/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/ubufox@ubuntu.com
1409862349354   addons.xpi  INFO    Mapping {2e1445b0-2682-11e1-bfc2-0800200c9a66} to /usr/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/{2e1445b0-2682-11e1-bfc2-0800200c9a66}
1409862349355   addons.xpi  INFO    Mapping langpack-en-ZA@firefox.mozilla.org to /usr/lib/firefox/browser/extensions/langpack-en-ZA@firefox.mozilla.org.xpi
1409862349355   addons.xpi  INFO    Mapping langpack-en-GB@firefox.mozilla.org to /usr/lib/firefox/browser/extensions/langpack-en-GB@firefox.mozilla.org.xpi
1409862349355   addons.xpi  INFO    Mapping {972ce4c6-7e08-4474-a285-3208198ce6fd} to /usr/lib/firefox/browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}
1409862349355   addons.xpi  INFO    Mapping langpack-ar@firefox.mozilla.org to /usr/lib/firefox/browser/extensions/langpack-ar@firefox.mozilla.org.xpi
1409862349356   addons.xpi  DEBUG   Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous3480147629030289426webdriver-profile/extensions/webdriver-staging
1409862349356   addons.xpi  INFO    Mapping fxdriver@googlecode.com to /tmp/anonymous3480147629030289426webdriver-profile/extensions/fxdriver@googlecode.com
1409862349357   addons.xpi  DEBUG   checkForChanges
1409862349363   addons.xpi  DEBUG   No changes found
1409862349367   addons.xpi  DEBUG   Registering manifest for /usr/lib/firefox/browser/extensions/langpack-en-ZA@firefox.mozilla.org.xpi
1409862349367   addons.xpi  DEBUG   Registering manifest for /usr/lib/firefox/browser/extensions/langpack-en-GB@firefox.mozilla.org.xpi
1409862349368   addons.xpi  DEBUG   Registering manifest for /usr/lib/firefox/browser/extensions/langpack-ar@firefox.mozilla.org.xpi
*** Blocklist::_preloadBlocklistFile: blocklist is disabled
   JavaScript error: chrome://browser/content/urlbarBindings.xml, line 677: aUrl is undefined

    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:250)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:112)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:195)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:190)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:99)

解决方案:我终于设法解决了这个问题,我将 selenium webDriver 版本从 2.42.2 更改为 2.39.0 并将 firefox 版本从 32.0 降级为 28.0

4

5 回答 5

5

在 Windows 7 上更新 FireFox 32 和 Selenium Firefox Webdriver 2.40.0 时遇到了同样的异常。我将在这里发布我的解决方案,也许它不能解决您的问题,但它可能是其他有同样问题的人的解决方案搜索后降落在这里。

不知何故,selenium-remote-driver它没有得到正确更新,而它存在于selenium-firefox-driver. 我的解决方案是将远程驱动程序添加到我自己的 POM 中:

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-firefox-driver</artifactId>
    <version>2.43.1</version>
</dependency>
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-remote-driver</artifactId>
    <version>2.43.1</version>
</dependency>

我不得不重新启动我的 IDE (IntelliJ) 并重建项目,但之后它工作了。

最终配置:

  • 火狐 32.0.3
  • Selenium FireFox 驱动程序 2.43.1
  • Selenium 远程驱动程序 2.43.1
于 2014-09-29T15:47:45.240 回答
0

请尝试较旧的 FF 构建。目前我也观察到此类问题 FF build no 32 with latest selenium 但是在将更改恢复到较旧的构建后,我的问题得到成功解决。

于 2014-09-05T07:20:25.523 回答
0

Try to use an older version of FirefoxDriver.

Use the older FirefoxDriver (e.g.: 2.39) with Firefox 32.

于 2014-09-04T20:07:34.480 回答
0

您在两者之间遇到了一些兼容性问题。最简单的方法是找到与 ubuntu 32.0 兼容的版本

于 2014-09-04T19:58:59.757 回答
0

如果在导入 jar 后第一次执行 selenium 代码

右键单击项目->构建路径->配置构建路径...->订购和导出->获取 JRE 库下方的 selenium java,server-standalone jars->确定

重新执行代码,它会工作。

于 2017-11-01T12:24:39.830 回答