Scenario.embed error : Cannot resolve method 'embed' in 'Scenario'

Scenario.embed error : Cannot resolve method 'embed' in 'Scenario'

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

我的挂钩文件的一部分

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

我导入了以下内容:

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;

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

我不确定为什么会遇到这个问题,我已经尝试降级我的黄瓜,google 出现错误,但不知何故嵌入无法正常工作。

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

embed() 方法已弃用并从 6.0 Documentation.

中删除
public void attach​(byte[] data, String mediaType, String name)
Attach data to the report(s).
 
 // Attach a screenshot. See your UI automation tool's docs for
 // details about how to take a screenshot.
 scenario.attach(pngBytes, "image/png", "Bartholomew and the Bytes of the Oobleck");
 
 
To 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.



Parameters:
data - what to attach, for example an image.
mediaType - what is the data?
name - attachment name