private static final int max_sleep_total = 20; // 超时最大值
static void click(By by) {
boolean Location = false;
int sleep_total = 0;
while ((!Location) && (sleep_total <= max_sleep_total)) {
try {
driver.findElement(by).click();
Location = true;
System.out.println("单击成功:" + by);
} catch (Exception e) {
System.out.println("单击成功:" + by);
sleep(2000);
sleep_total += 2;
System.out.println("总共已等待 " + sleep_total + " 秒");
}
}
if (!Location) {
RunExcelCase.judge = "fail";
System.out.println("最终单击失败:" + by);
snapshot("点击失败");
}
}