我可以使用gradle运行宁静测试用例。我使用命令$ 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);
}
}
你能帮我解决这个问题。提前致谢