gpt4 book ai didi

java - 如果元素出现,如何关闭?

转载 作者:行者123 更新时间:2023-11-30 05:38:40 25 4
gpt4 key购买 nike

我将使用什么命令来关闭此元素,如果它在运行时出现。我希望我的代码能够注意到它何时出现,但如果它没有出现,则按常规优先级继续。

enter image description here

最佳答案

//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
}

关于java - 如果元素出现,如何关闭?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56141387/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com