简体   繁体   English

方法未找到,cucumber 测试

[英]Method not found, cucumber tests

Hey fellow hackermann:)嘿,hackermann 伙伴:)

I have a problem with my cucumber Tests:我的 cucumber 测试有问题:

I would like to take screenshots during my testing and embed the screenshot into my Scenario我想在测试期间截取屏幕截图并将屏幕截图嵌入到我的场景中

the code I am using for this is:我为此使用的代码是:

private void makeSnapshot (String name){
        final byte[] screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
        this.scenario.embed(screenshot, "image/png",name);
        //return screenshot;
    }

My pom file looks like this:我的 pom 文件如下所示:

<?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>org.example</groupId>
    <artifactId>SeleniumCucumber</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>

        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>6.2.1</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-html -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-html</artifactId>
            <version>0.2.7</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/net.sourceforge.cobertura/cobertura -->
        <dependency>
            <groupId>net.sourceforge.cobertura</groupId>
            <artifactId>cobertura</artifactId>
            <version>2.1.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>5.6.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>6.2.0</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-jvm-deps -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-jvm-deps</artifactId>
            <version>1.0.6</version>
            <scope>provided</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/net.masterthought/cucumber-reporting -->
        <dependency>
            <groupId>net.masterthought</groupId>
            <artifactId>cucumber-reporting</artifactId>
            <version>5.3.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-core -->
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
            <version>2.2</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.cucumber/gherkin -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>gherkin</artifactId>
            <version>5.1.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/junit/junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>



    </dependencies>


</project>

The error message:错误信息:

在此处输入图像描述

I guess I am using a wrong dependency, but I don't know which is wrong as I am fairly new to the whole subject我想我使用了错误的依赖项,但我不知道哪个是错误的,因为我对整个主题相当陌生

The method is NOT depricated (already checked)该方法未贬低(已检查)

Has anyone any idea how to fix this, any help is awesome有谁知道如何解决这个问题,任何帮助都很棒

Thank you in advance先感谢您

Your dependencies are inconsistent.您的依赖关系不一致。 You are including different incompatible versions of cucumber dependencies as well as transitive dependencies.您包括 cucumber 依赖项以及传递依赖项的不同不兼容版本。

You should start from scratch with the https://cucumber.io/docs/guides/10-minute-tutorial/ and only add those dependencies you need.您应该从头开始使用https://cucumber.io/docs/guides/10-minute-tutorial/并只添加您需要的那些依赖项。

Since, you're using Cucumber-Core 6.2.1 , you should be using attach method which has the same signature.由于您使用的是 Cucumber-Core 6.2.1 ,因此您应该使用具有相同签名的attach方法。 Refer TestCaseState#attach参考TestCaseState#attach

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM