【发布时间】:2019-10-02 03:04:42
【问题描述】:
【问题讨论】:
-
可以分享HTML代码吗?
标签: java eclipse selenium automation appium
【问题讨论】:
标签: java eclipse selenium automation appium
您可以检查与 id/class 匹配的元素数量,然后仅在至少有 1 个元素时单击。
List<WebElement> elements = driver.findElements(By.id("com.simplemobiletools.gallery:id/parentPanel"));
if (elements.size()>0){
elements.get(0).click();
}
【讨论】:
//You can change ExpectedConditions type (visibilityOfElementLocated)
public boolean isExist(By elementBy, int seconds) {
try {
WebDriverWait wait = new WebDriverWait(driver, seconds);
wait.until(ExpectedConditions.presenceOfElementLocated(elementBy));
return true;
} catch (Exception e) {
return false;
}
}
//if popup is displayed within 3 seconds
By POPUP = By.id("com.simplemobiletools.gallery:id/parentPanel");
if (isExist(POPUP, 3)) {
//do something - for example click cancel button
}
【讨论】: