如下:
//by对象是否存在
public boolean byElementIsExist(By by) {
try {
driver.findElement(by);
return true;
} catch (Exception e) {
// TODO: handle exception
return false;
}
}
// 调用
public void xXX() {
if(byElementIsExist(By.id("com.xxx.xxxxx:id/tv_bottom_left")) == true) {
assert true;
}else {
assert false:" 元素不存在 ";
}
}