assertconfirmation 的 Webdriver 等效项是什么? 我有以下 selenium IDE 代码,当导出到 JUnit 4 (Webdriver) 时会返回错误:
IDE代码:
<tr>
<td>click</td>
<td>link=Logout</td>
<td></td>
</tr>
<tr>
<td>assertConfirmation</td>
<td>Are you sure you want to logout?</td>
<td></td>
</tr>
导出的 Webdriver 代码与上面对应:
@Test
public void testUntitled2() throws Exception {
driver.findElement(By.linkText("Logout")).click();
// ERROR: Caught exception [ERROR: Unsupported command [getConfirmation]]
}
我过去能够成功地使用 RC 来使用以下内容,但使用 webdriver 时它不再起作用 - (请注意我正在尝试将我的脚本迁移到 webdriver)
assertTrue(selenium.getConfirmation().matches("^Are you sure you want to logout[\\s\\S]$"));
干杯
山
最佳答案
应该是这个!
final String text = "Are you sure you want to logout?";
assertTrue(driver.switchTo().alert().getText().equals(text));
...或者可能是您那里的“matches()”版本。
关于selenium - 断言确认的 webdriver 等效项是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10178584/