我可以使用 gradle 运行 serenity 测试用例。我使用命令$ gradle clean test aggregate
。报告也会生成,但是当我单击报告中提供的链接时,它无法导航并给出错误消息。我已经创建了下面链接中提到的包结构。
http://thucydides.info/docs/articles/an-introduction-to-serenity-bdd-with-cucumber.html
但是我仍然无法解决这个问题。下面是我的 Runner、Step 定义和存储库类。跑者类:
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(features = "src/test/resources/features/LoginFeatureSerenity.feature")
public class TestRunnerSerenity {
}
步骤定义类:
package org.gradle.stepdef;
public class LoginStepDefSerenity {
@Managed
public WebDriver driver;
@ManagedPages
public Pages pages;
LoginPageRepository page;
// Scenario 1: Verify New Serenity Test Case
@Step
@Given("^User is on LoginSerenity Page$")
public void user_is_on_LoginSerenity_Page() throws Throwable {
page.open();
}
@Step
@When("^User enters valid Serenity credentials$")
public void user_enters_valid_Serenity_credentials() throws Throwable {
page.setusername("kaustubhsaxena");
page.setpassword("saxenasdhfghjfg");
page.loginButton.click();
}
@Step
@Then("^User is able to login Serenity$")
public void user_is_able_to_login_Serenity() throws Throwable {
assertThat(page.loginValidationMessage.getText(), is("Login failed"));
// page.logoutButon.click();
driver.close();
}
}
存储库类
@DefaultUrl("http://localhost:8000/app/#/login")
public class LoginPageRepository extends PageObject {
@FindBy(id = "username")
protected WebElement username;
public void setusername(String value) {
element(username).type(value);
}
public WebElementFacade username() {
return element(username);
}
// Fields for Password
@FindBy(id = "password")
protected WebElement password;
public void setpassword(String value) {
element(password).type(value);
}
public WebElementFacade password() {
return element(password);
}
}
你能帮我解决这个问题吗?提前致谢