gpt4 book ai didi

java - 如何在新的浏览器实例中运行每个 cucumber 功能?

转载 作者:行者123 更新时间:2023-11-29 09:30:10 35 4
gpt4 key购买 nike

为了消除依赖和方便功能之间的并行执行,我想在其自己的浏览器实例中运行每个功能。

我目前有这个设置。将不胜感激。

@CucumberOptions(..., features = "/features/"...)

public class RunCukes {
public static WebDriver driver = new FirefoxDriver();
}

我的特点...

Feature: Feature-1
Scenario: A Scenario

Give I login as "<user>"
...

Feature: Feature-2
Scenario: A Scenario

Give I login as "<user>"

步骤定义...

@Given("^I login as \"([^\"]*)\"$")
public void I_login_as(String user) throws Throwable {
try {
driver.get("url");
} catch (Exception e) {
//do something ( e.g.take screenshot ) and close browser
}
}
...

最佳答案

您必须为每个功能初始化WebDriver,最好在@Before

@cucumber.annotation.Before;
public void init() {
driver = new FirefoxDriver();
}

@cucumber.annotation.After;
public void close() {
driver.quit();
}

关于java - 如何在新的浏览器实例中运行每个 cucumber 功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20950111/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com