运行功能测试时出现错误。这与登录页面中的 webdriver 构造函数有关吗?我无法弄清楚为什么我会收到此错误:
cucumber.runtime.CucumberException:类 step_definitions.LoginSteps 没有空构造函数。如果您需要 DI,请将 cucumber-picocontainer 放在类路径中...
我的 pom info.cukes cucumber-picocontainer 1.2.4 中有 picocontainter
public class LoginSteps {
private final LoginPage login;
SharedDriver driver;
public LoginSteps(LoginPage login, SharedDriver driver) {
this.login=login;
this.driver=driver;
}
@Given("^the Pctice Login page is loaded$")
public void the_Poactice_Login_is_loaded ()throws Throwable {
driver.getDriver().get("....ogin/");
}
@When("^The logins into the account$")
public void the_logins_into_the_account() throws Throwable {
login.login(false);
}
这是我的登录页面
public class LoginPage extends BaseClass {
private final By username = By.id("userName");
private final By password= By.id("password");
private final By submit= By.id("submit_0");
public LoginPage(WebDriver driver){
super(driver);
}
public HomePage login(Boolean newuser) throws InterruptedException {
DataFactory log= new DataFactory();
if (newuser) {
Thread.sleep(5000);
driver.findElement(username).click();
driver.findElement(username).sendKeys(log.getFirstName());
driver.findElement(password).sendKeys(log.getFirstName());
} else {
driver.findElement(username).click();
}
return new HomePage(driver);
}}
