selenium-webdriver - @AfterStep/@BeforeStep 不适用于 Cucumber Selenium Java
问题描述
我在黄瓜硒java项目中苦苦挣扎@AfterStep/@Beforestep。
当我使用 @AfterStep 黄瓜钩子时,它不执行该方法(它跳过该方法)
我尝试了很多版本,但仍然没有运气。
谁能帮我处理没有兼容性问题的最新版本的 POM 文件
我把这个文件放在 stepDefinition 并使用 cucumber.api.java.AfterStep
@AfterStep
public void tearDown(Scenario scenario) throws IOException, JiraException
{
System.out.println("in step method");
if (scenario.isFailed()) {
System.out.println("in failes screen");
File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
String path=null;
path=System.getProperty("user.dir")+"\\target\\Screenshot\\"+System.currentTimeMillis()+".png";
FileUtils.copyFile(scrFile, new File(path));
Reporter.addScreenCaptureFromPath(path);
Reporter.addStepLog(scenario.getId());
}
}
测试运行者:
@RunWith(Cucumber.class)
@CucumberOptions(
features = {"src/extentPackage/LoginToABSi.feature"},
glue = {"stepDefinitions"},
plugin = {"com.cucumber.listener.ExtentCucumberFormatter:target/report.html"}
)
public class RunCukesTest {
public static WebDriver driver;
public static WebDriverWait wait;
public static ExtentProperties extentProperties;
@AfterClass
public static void teardown() {
Reporter.loadXMLConfig(new File("Report-Config/extent-config.xml"));
Reporter.setSystemInfo("user", System.getProperty("user.name"));
Reporter.setSystemInfo("os", "Mac OSX");
Reporter.setTestRunnerOutput("Sample test runner output message");
}
解决方案
推荐阅读
- racket - 如何从 Racket 的矩阵中逐行获取元素?
- javascript - TypeError:无法读取未定义的属性“字符”
- css - 在一个元素上反应原生动画多个动画
- android - gradle withJavadocJar() 和 withSourcesJar() 用于 android 库
- c# - 通过优先合并其他三个来创建对象(C# .NET 3.5)
- java - 将代码从php转换为java。我转换了大部分代码,但我仍然遇到一些错误
- sql - 为了以不同的查询定义采用不同的参数的方式实施 MS Access Report,需要采取哪些步骤?
- java - GSON:如何从 json 解码为忽略对象的模型?
- bigdata - matillion和apache气流之间的区别
- node.js - 从嵌入式 MongoDB 文档中的数组中提取对象