【发布时间】:2017-11-10 11:22:43
【问题描述】:
我正在使用 Cucumber 和 Selenium WebDriver 来测试应用程序,并且我刚刚注意到我的测试正在通过特定区域,无论我在“ExpectedConditions.textToBe”方法的参数中添加什么。
这部分测试简单地检查在测试添加用户后正确的文本是否出现在用户角色表中:
public void admin_can_see_the_new_role_in_the_list() throws Throwable {
// Write code here that turns the phrase above into concrete actions
//throw new PendingException();
Thread.sleep(3000);
ExpectedConditions.textToBe(By.xpath("//*[@id=\"role-nbbbamze\"]"), "account manasdfsdfger");
ExpectedConditions.textToBe(By.xpath("//*[@id=\"app\"]/dizz/dib[2]/divz/div[2]zzz/table/tbody/tr[11]/td[2]"), "Accmasfsdnager");
ExpectedConditions.textToBe(By.xpath("//*[@id=\"app\"]/dbiv/div[2]/div/dziv[2]/tzable/tzzzbody/tr[11]/td[3]"), "Can acvfcess the normal dashboard");
}
如您所见,我在参数中添加了随机字符,测试运行并仍然通过。它应该失败,因为我定义的 xpath 不存在 - 或者我断言的文本与该 xpath 中的任何内容都不匹配。
我显然用错了 ExpectedConditions,但我不知道在哪里或如何。
提前谢谢大家!
【问题讨论】:
标签: java selenium selenium-webdriver cucumber