简体   繁体   English

Selenium chrome driver error java.lang.AbstractMethodError: Receiver class org.openqa.selenium.chrome.ChromeDriverService$Builder does not define

[英]Selenium chrome driver error java.lang.AbstractMethodError: Receiver class org.openqa.selenium.chrome.ChromeDriverService$Builder does not define

I did not have problem to run this before becoming messy with something.在弄乱某些东西之前,我运行它没有问题。

Any help would be appciated.任何帮助都会被应用。

I am getting this error chrome driver when running any test class with chrome driver.使用 chrome 驱动程序运行任何测试 class 时出现此错误 chrome 驱动程序。

I tried to put chrome driver options, but still not working.我尝试放置 chrome 驱动程序选项,但仍然无法正常工作。 I upgraded chrome driver version and some other frameworks, but still same error.我升级了 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)

class class

@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);
    }

If I add headless on options, they say如果我在选项上添加无头,他们会说

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 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>

Your help would be appreciated.您的帮助将不胜感激。 Thanks,谢谢,

You need to pass the absolute path of the ChromeDriver executable through the System.setProperty() line as follows:您需要通过System.setProperty()行传递ChromeDriver可执行文件的绝对路径,如下所示:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 线程“main”中的异常 java.lang.AbstractMethodError:接收器类 org.openqa.selenium.chrome.ChromeOptions 未使用 Selenium 定义错误 - Exception in thread "main" java.lang.AbstractMethodError: Receiver class org.openqa.selenium.chrome.ChromeOptions does not define error using Selenium 线程“主”中的异常 java.lang.AbstractMethodError: org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Ljava/util/List; - Exception in thread "main" java.lang.AbstractMethodError: org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Ljava/util/List; Spring 启动:java.lang.AbstractMethodError:接收器类 org.springframework.jms.config.JmsListenerEndpointRegistry - Spring boot : java.lang.AbstractMethodError: Receiver class org.springframework.jms.config.JmsListenerEndpointRegistry org.openqa.selenium.WebDriverException:未知错误:chrome 无法通过 Java 开始使用 Selenium ChromeDriver 和 Chrome - org.openqa.selenium.WebDriverException: unknown error: chrome failed to start using Selenium ChromeDriver and Chrome through Java java.lang.AbstractMethodError:接收器类 io.cucumber.testng - java.lang.AbstractMethodError: Receiver class io.cucumber.testng org.openqa.selenium.WebDriverException:未知错误:无法通过Java用ChromeDriver Chrome和Selenium集中元素 - org.openqa.selenium.WebDriverException: unknown error: cannot focus element with ChromeDriver Chrome and Selenium through Java org.openqa.selenium.WebDriverException: disconnected: not connected to DevTools error using ChromeDriver Chrome using Selenium and Java - org.openqa.selenium.WebDriverException: disconnected: not connected to DevTools error using ChromeDriver Chrome using Selenium and Java 我在 jmeter 中的插件抛出 java.lang.NoSuchMethodError: org.openqa.selenium.chrome.ChromeOptions.setBinary - My plugin in jmeter throws java.lang.NoSuchMethodError: org.openqa.selenium.chrome.ChromeOptions.setBinary 收到错误-java.lang.ClassCastException:org.openqa.selenium.chrome.ChromeDriver无法转换为com.initialization.DriverInitialization - Getting the Error - java.lang.ClassCastException: org.openqa.selenium.chrome.ChromeDriver cannot be cast to com.initialization.DriverInitialization org.openqa.selenium.NoSuchSessionException:在使用 ChromeDriver Chrome 和 Java 的 Selenium 自动化测试中没有这样的会话错误 - org.openqa.selenium.NoSuchSessionException: no such session error in Selenium automation tests using ChromeDriver Chrome with Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM