Seleniumchrome驱动程序错误java.lang.AbstractMethodError:接收器类org.op



在遇到麻烦之前,我运行这个程序没有问题。

任何帮助都将不胜感激。

当我用chrome驱动程序运行任何测试类时,我都会得到这个错误chrome驱动。

我试着把铬驱动程序的选项,但仍然没有工作。我升级了chrome驱动程序版本和其他一些框架,但仍然存在相同的错误。

@RunWith(Cucumber.class)
@CucumberOptions(features="src/test/Features", glue= {"StepDefinitions"},
monochrome = true,
plugin = {"pretty", "junit:target/junit/report.xml",
"html:target/html/HtmlReports",
"json:target/JSONReports/report.json"},
tags="@Sorting_HL"

> java.lang.AbstractMethodError: Receiver class
> org.openqa.selenium.chrome.ChromeDriverService$Builder does not define
> or inherit an implementation of the resolved method 'abstract
> java.util.List createArgs()' of abstract class
> org.openqa.selenium.remote.service.DriverService$Builder.     at
> org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:441)
>   at
> org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:94)
>   at
> org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:157)
>   at
> StepDefinitions.COB_sorting_2.sorting_tab_is_seen(COB_sorting_2.java:57)
>   at ✽.Sorting tab is seen.(file:///folder/src/test/Features/sorting.feature:50)

@Given("Sorting tab is seen.")
public void sorting_tab_is_seen() throws IOException {
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
String url = "url address";
ChromeOptions chromeOptions = new ChromeOptions();

//      chromeOptions.addArguments("--headless"); 
//  chromeOptions.addArguments("no-sandbox");
driver= new ChromeDriver(chromeOptions);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get(url);
}

如果我在选项上加上无头,他们说

java.lang.NoSuchMethodError: 'org.openqa.selenium.chromium.ChromiumOptions org.openqa.selenium.chrome.ChromeOptions.addArguments(java.lang.String[])'
at StepDefinitions.COB_sorting_2.sorting_tab_is_seen(COB_sorting_2.java:55)
at ✽.Sorting tab is seen.(file:///folder/src/test/Features/sorting.feature:50)

pom-xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.eCommerce</groupId>
<artifactId>mavenProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>mavenProject</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<suiteXmlFile>src/main/testng.xml</suiteXmlFile>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.4.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.0.0</version>
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.0.0</version>
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
<version>6.11.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.masterthought/maven-cucumber-reporting -->
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>5.3.0</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>8.0.0-beta</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-testng -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>7.1.0</version>
</dependency>

</dependencies>
<build>
<!-- <pluginManagement> lock down plugins versions to avoid using Maven 
defaults (may be moved to parent pom)
</pluginManagement>
-->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<!-- 
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>
-->
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- 
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>2.8.0</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>mavenProject</projectName>
<outputDirectory>${project.build.directory}/cucumber-report-html</outputDirectory>
<cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
</configuration>
</execution>
</executions>
</plugin>
-->
</plugins>

</build>
</project>

非常感谢您的帮助。谢谢,

您需要通过System.setProperty((行传递ChromeDriver可执行文件的绝对路径,如下所示:

System.setProperty("webdriver.chrome.driver", "C:\path\to\chromedriver.exe");

昨天,甚至我也面临着同样的问题,在构建生成过程之后,我的测试脚本突然停止了工作。我在背后做了大量的研究,但一无所获。根据堆栈跟踪,错误显示"AppiumServiceBuilder没有定义或继承抽象类org.openqa.selene.remote.service.DriverService$Builder的已解析方法"abstract void loadSystemProperties(("的实现;其中,DriverService类的子类AppiumServiceBuilder不覆盖/实现其抽象方法。我们花了一整天的时间来讨论这个问题。幸运的是,一位Java开发人员打开了";appium客户端";jar文件,以获取适当的Selenium版本参考(main.properties文件(。作为一个IDE,我们使用IntelliJ的想法,我们检查了项目结构。我们发现,selenium的一些依赖Jar文件引用了最新版本的selenium。为此,我们手动添加了适当的版本依赖项。我们的问题解决了。

"在一个坚果壳"-Appium客户端引用了一个依赖项,但它没有得到抽象方法的实现。由于与硒相关的依赖性正从另一个版本得到解决。因此,它突然失败了。我们将硒依赖关系修复为正确的版本,它就开始工作了。

相关内容

  • 没有找到相关文章

最新更新