问题描述
当我尝试单击“编辑条件”时,出现异常。请有人可以帮助我
public void selectCriteriaFromWorklistsOptions() {
waitABit(Constants.medium);
for (int i = 0; i < 3; i++) {
try {
WebElement dropDown = getDriver().findElement(By.cssSelector(div.nav-menu__group > ul:nth-child(2) > li:nth-child(1) > button:nth-child(1)));
dropDown.click();
break;
} catch (Exception e) {
logger.debug((e.getMessage()));
}
}
}
另外,我也试过这个 -
WebElement element = waitForCondition().until(ExpectedConditions.elementToBeClickable(By.xpath("//button[contains(text(),'Edit criteria')])")));
element.click();
解决方法
等待该元素变为可点击状态。
并尝试使用以下 css selector
:
.bttn-menu"
或者:
.nav-menu_bttn>.bttn-menu
尝试 2:
button[bss-bttn-menu]
尝试 3: 在 Java 中应该是这样的:
WebDriverWait wait = new WebDriverWait(driver,10);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(.nav-menu_bttn>button[bss-bttn-menu]")));
自己检查下划线的数量_。大概有两个。