单击多个按钮的 Serenity BDD 测试
Serenity BDD testing for clicking multiple buttons
我创建了一个宁静测试。它的作用是打开 Google,然后搜索 online calculator
。那么它应该:
- 点击 1
- 点击+
- 点击 1
- 点击=
我的代码是:
givenThat(gdguradio).wasAbleTo(openTheApplication);
when(gdguradio).attemptsTo(Search.forTheTerm("online calculator"));
when(gdguradio).attemptsTo(EnterInFormula.forEnteringinFormula());
//guradio.AddingTwoNumbers();
guradio.shouldSeeSumEquals("3");
然后我的EnterInFormula.forEnteringinFormula()
@Step("{0} clears all the completed items")
public <T extends Actor> void performAs(T actor) {
actor.attemptsTo(Click.on(SearchBox.NumberOne));
actor.attemptsTo(Click.on(SearchBox.NumberPlus));
actor.attemptsTo(Click.on(SearchBox.NumberTwo));
actor.attemptsTo(Click.on(SearchBox.NumberEquals));
}
public static EnterInFormula forEnteringinFormula() {
return instrumented(EnterInFormula.class);
}
我的搜索框:
public class SearchBox {
public static Target SEARCH_FIELD = Target.the("search field").located(By.name("q"));
public static Target CalculatorFormula = Target.the("Calculator Formula").located(By.id("cwos"));
public static Target NumberOne = Target.the("1").located(By.id("cwbt33"));
public static Target NumberTwo = Target.the("2").located(By.id("cwbt34"));
public static Target NumberPlus = Target.the("+").located(By.id("cwbt46"));
public static Target NumberEquals = Target.the("=").located(By.id("cwbt45"));
}
在按下按键之前看起来还不错。它只按数字 2,因此测试失败。
如何正确书写按钮的点击?
代码看起来不错。这看起来像是一个正常的 Selenium 自动化问题 - Selenium 表示该元素未启用,因此对于 Selenium 来说,它可能不是。在按钮准备好单击之前,您可能需要等待某些事件或状态。
我创建了一个宁静测试。它的作用是打开 Google,然后搜索 online calculator
。那么它应该:
- 点击 1
- 点击+
- 点击 1
- 点击=
我的代码是:
givenThat(gdguradio).wasAbleTo(openTheApplication);
when(gdguradio).attemptsTo(Search.forTheTerm("online calculator"));
when(gdguradio).attemptsTo(EnterInFormula.forEnteringinFormula());
//guradio.AddingTwoNumbers();
guradio.shouldSeeSumEquals("3");
然后我的EnterInFormula.forEnteringinFormula()
@Step("{0} clears all the completed items")
public <T extends Actor> void performAs(T actor) {
actor.attemptsTo(Click.on(SearchBox.NumberOne));
actor.attemptsTo(Click.on(SearchBox.NumberPlus));
actor.attemptsTo(Click.on(SearchBox.NumberTwo));
actor.attemptsTo(Click.on(SearchBox.NumberEquals));
}
public static EnterInFormula forEnteringinFormula() {
return instrumented(EnterInFormula.class);
}
我的搜索框:
public class SearchBox {
public static Target SEARCH_FIELD = Target.the("search field").located(By.name("q"));
public static Target CalculatorFormula = Target.the("Calculator Formula").located(By.id("cwos"));
public static Target NumberOne = Target.the("1").located(By.id("cwbt33"));
public static Target NumberTwo = Target.the("2").located(By.id("cwbt34"));
public static Target NumberPlus = Target.the("+").located(By.id("cwbt46"));
public static Target NumberEquals = Target.the("=").located(By.id("cwbt45"));
}
在按下按键之前看起来还不错。它只按数字 2,因此测试失败。
如何正确书写按钮的点击?
代码看起来不错。这看起来像是一个正常的 Selenium 自动化问题 - Selenium 表示该元素未启用,因此对于 Selenium 来说,它可能不是。在按钮准备好单击之前,您可能需要等待某些事件或状态。