Scenario.embed 错误:无法解析“场景”中的方法“嵌入”

rua*_*it2 0 java cucumber

我有一个黄瓜项目。如果我想截取屏幕截图,我想使用以下命令将其嵌入。 scenario.embed(((TakesScreenshot)driver).getScreenshotAs(OutputType.BYTES), "image/png");但是我收到错误embed-Cannot resolve method 'embed' in 'Scenario'

我的 hooks 文件的一部分

 @After
    public void teardownAndScreenshotOnFailure(Scenario scenario){
        try {
            if(driver != null && scenario.isFailed())
            {
                scenario.embed(((TakesScreenshot)driver).getScreenshotAs(OutputType.BYTES), "image/png");
            }
            if(driver != null)
            {
                driver.manage().deleteAllCookies();
                driver.quit();
                driver = null;
            }
            ....
Run Code Online (Sandbox Code Playgroud)

我导入了以下内容:

import io.cucumber.java.After;
import io.cucumber.java.Before;
import io.cucumber.java.Scenario;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
Run Code Online (Sandbox Code Playgroud)

我在 POM.xml 中使用最新版本的黄瓜:6.9.1

我不知道为什么会出现这个问题,我尝试降级我的黄瓜,谷歌搜索错误,但 shhomehow 嵌入不起作用。嵌入错误

Rah*_*l L 5

根据 6.9.1 的 Java 文档。您可以使用 Attach() 方法。

\n

embed()方法已弃用,并从 6.0文档中删除。

\n
public void attach\xe2\x80\x8b(byte[] data, String mediaType, String name)\nAttach data to the report(s).\n \n // Attach a screenshot. See your UI automation tool\'s docs for\n // details about how to take a screenshot.\n scenario.attach(pngBytes, "image/png", "Bartholomew and the Bytes of the Oobleck");\n \n \nTo ensure reporting tools can understand what the data is a mediaType must be provided. For example: text/plain, image/png, text/html;charset=utf-8.\n\n\n\nParameters:\ndata - what to attach, for example an image.\nmediaType - what is the data?\nname - attachment name\n
Run Code Online (Sandbox Code Playgroud)\n