1、Asser类提供的断言
assertTrue(web对象.isSelected()):是Asser类提供的断言,web对象.isSelected()用于判断单选或者多选按钮是否被选中且返回值是true或者false
例子:
import org.testng.Assert;
//是否启用
WebElement wqy_n=fFinds(dr, By.name("product.enable")).get(0);
if(!wqy_n.isSelected()){//该单选按钮未被选中时则点击选中
wqy_n.click();
//assertTrue
Assert.assertTrue(wqy_n.isSelected());//断言
}else {
System.out.println("单选按钮已被选中");
}
例子:
String actual=fFind(dr, By.className("messager-body panel-body panel-body-noborder window-body")).findElements(By.tagName("div")).get(1).getText();
Assert.assertEquals("添加成功", actual);//判断是否与预期的值一样