// 从源代码查找字符串,断言
static void assertString(String string) {
try {
sleep(3000);
Assert.assertTrue(driver.getPageSource().contains(string));// 从页面源码查找是否包含字符串
System.out.println("断言字符串成功: " + string);
} catch (AssertionError e) {
RunExcelCase.judge = "fail";
snapshot("断言字符串失败:" + string);
System.out.println("断言字符串失败: " + string);
}
}
// 断言元素上的text是否和预期一致
static void assertElementText(By by, String string1) {
String xpath_text = getElementText(by);
try {
Assert.assertEquals(xpath_text, string1);
System.out.println("断言text成功,预期结果:" + string1 + " 实际结果;" + xpath_text);
} catch (AssertionError e) {
RunExcelCase.judge = "fail";
snapshot("断言text失败&#x
selenium3.0断言各种结果
最新推荐文章于 2024-01-08 15:34:25 发布