为了消除依赖关系并提供便利 在功能之间并行执行,我想在自己的浏览器实例中运行每个功能。
我目前有这个设置。会很感激方向。
@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
}
}
...
答案 0 :(得分:-1)
您必须为每个功能初始化WebDriver
,最好是@Before
@cucumber.annotation.Before;
public void init() {
driver = new FirefoxDriver();
}
@cucumber.annotation.After;
public void close() {
driver.quit();
}