TA的每日心情 | 无聊 2020-12-8 11:20 |
---|
签到天数: 605 天 连续签到: 1 天 [LV.9]测试副司令
|
断言是测试框架里的,和selenium没有关系的,你断言想怎么写就可以怎么写哈,2.0里面遇到Alert可以这么去搞:
try {
//Get the Alert
Alert alert = driver.switchTo().alert();
//Get the Text displayed on Alert using getText() method of
Alert class
String textOnAlert = alert.getText();
//Click OK button, by calling accept() method of Alert Class
alert.accept();
//Verify Alert displayed correct message to user
assertEquals("Hello! I am an alert box!",textOnAlert);
} catch (NoAlertPresentException e) {
e.printStackTrace();
} |
|