【问题标题】:Serenity BDD testing for clicking multiple buttons用于单击多个按钮的 Serenity BDD 测试
【发布时间】:2018-07-04 04:04:22
【问题描述】:

我创建了一个宁静测试。它的作用是打开谷歌然后搜索online calculator。那么它应该:

  1. 点击 1
  2. 点击+
  3. 点击 1
  4. 点击=

我的代码是:

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,因此测试失败。

如何正确书写按钮的点击?

【问题讨论】:

    标签: windows netbeans cmd automated-tests serenity-bdd


    【解决方案1】:

    代码看起来不错。这看起来像一个正常的 Selenium 自动化问题 - Selenium 表示该元素未启用,因此对于 Selenium,它可能不是。在按钮准备好单击之前,您可能需要等待某些事件或状态。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多