【问题标题】:How to fix: Error message in TestNG java.lang.AbstractMethodError: org.openqa.selenium.MutableCapabilities.is(Ljava/lang/String;)Z如何修复:TestNG java.lang.AbstractMethodError 中的错误消息:org.openqa.selenium.MutableCapabilities.is(Ljava/lang/String;)Z
【发布时间】:2018-04-25 04:00:25
【问题描述】:

如何解决以下错误信息

java.lang.AbstractMethodError: org.openqa.selenium.MutableCapabilities.is(Ljava/lang/String;)Z in 使用 Java、Selenium Server 的自动化项目(具有 配置:client-combined-3.7.1-sources,client-combined-3.7.1, 常见的 ns-lang-2.6, org.eclipse.jgit_4.5.0.201609210915-r, selenium-firefox-driver-3.0.0-beta1,selenium-server-standalone-3.7.1 Firefox v. 44)

我尝试了许多 selenium 服务器和 selenium Firefox 驱动程序的组合,但我收到了其他错误

<dependencies> 
  <dependency> 
    <groupId>org.testng</groupId> 
    <artifactId>testng</artifactId> 
    <version>6.8.8</version> 
    <scope>test</scope> 
  </dependency> 
  <dependency> 
    <groupId>org.seleniumhq.selenium</groupId> 
    <artifactId>selenium-java</artifactId> 
    <version>3.7.1</version> 
  </dependency> 
</dependencies>

我只使用这几行代码:

System.setProperty("webdriver.gecko.driver", "C:\\Users\\Aila\\Downloads\\geckodriver-v0.19.1-win32\\geck‌​odriver.exe"); 
driver = new FirefoxDriver(); 

【问题讨论】:

  • 您能在问题中显示您项目的 Maven 配置的 XML 吗?特别是dependencies 部分。
  • org.testngtestng6.8.8testorg.seleniumhq.seleniumselenium-java3.7.1
  • 无论如何我没有从 pom 文件运行测试,我只是使用 Run as TestNG 运行
  • 您从 2016 年 9 月开始使用selenium-firefox-driver-3.0.0-beta(超过 1 年),而最新版本是:Selenium Firefox Driver 3.7.1
  • 感谢您的回复,我添加了它,但我遇到了同样的错误。

标签: maven selenium selenium-firefoxdriver selenium-server


【解决方案1】:

错误说明了一切:

java.lang.AbstractMethodError: org.openqa.selenium.MutableCapabilities.is(Ljava/lang/String;)Z in automation project with Java, Selenium Server (having the configuration : client-combined-3.7.1-sources, client-combined-3.7.1, commo ns-lang-2.6, org.eclipse.jgit_4.5.0.201609210915-r, selenium-firefox-driver-3.0.0-beta1, selenium-server-standalone-3.7.1

首先确保您使用的是最新版本的所有二进制文件和 jar(SeleniumGeckoDriverFirefox 浏览器)。


如果你想使用Maven

  • 从项目中删除您手动添加的所有与 Selenium 相关的 jar。
  • 仅通过 Maven 依赖项使用 SeleniumTestNG 相关的 jar。
  • 清理项目
  • 执行mvn clean install test

如果你想在没有 Maven 的情况下使用 SeleniumTestNG

  • 一次性删除所有与 Selenium 相关的 jar,并在您的项目中仅添加 selenium-server-standalone-3.7.1
  • 清理项目
  • TestNG TestTestNG Suite 的形式执行您的 @Test

【讨论】:

  • 感谢您的回答,但似乎我所做的一切都面临同样的错误。我有以下罐子:selenium 3.7.1、webdriver 1.6.2、testng 11.6。我做了干净的项目,mvn clean install test;仍然显示相同的错误
  • 现在我面临另一个绝对奇怪的错误找不到类路径中的类:Tests.CreateDeviceTest at org.testng.xml.XmlClass.loadClass(XmlClass.java:81) at org.testng.xml.XmlClass .init(XmlClass.java:73) 在 org.testng.xml.XmlClass.(XmlClass.java:59) 在 org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:582) 在 com.sun。 org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
  • 我最近在进行 mvn 构建时出现的错误是:[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile)关于项目 RegAutoProject:编译失败:编译失败:[ERROR] /C:/Users/Aila/workspace/my/src/main/java/DEWA/ScheduledReportsUsagePatternsChargeCycles.java:[101,83] 用于编码 UTF-8 的不可映射字符 [错误] /C:/Users/Aila/workspace/my/src/main/java/DEWA/ScheduledReportsUsagePatternsChargeCycles.java:[179,83] 用于编码 UTF-8 的不可映射字符
  • mvn clean、mvn install、mvn build 和 mvn test 正在工作,但是当我作为 TestNG 运行时,我收到的错误是:java.lang.AbstractMethodError: org.openqa.selenium.chrome。 ChromeOptions.is(Ljava/lang/String;)Z 在 org.openqa.selenium.remote.RemoteWebDriver.init(RemoteWebDriver.java:170) 在 org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java: 123) 在 org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:181) 在 org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:168)
【解决方案2】:

这个问题有两种解决方案:

  1. 在 Selenium 项目中添加正确的版本,因为不同的版本对于我的问题 selenium-server-standalone-2.42.2.jar 没有相同的解决方案是正确的。
  2. 如果此问题的任何解决方案都无法解决,请尝试此选项。

打开 Windows 命令提示符并键入以下命令:
java -Dwebdriver.gecko.driver="C:\NewAutomationCICD\resource\chromedriver.exe" -jar C:\NewAutomationCICD\libs\selenium-server-standalone-2.42.2.jar

【讨论】:

    猜你喜欢
    • 2012-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-16
    相关资源
    最近更新 更多