以下内容可能会帮助您满足要求。在下面的代码中,我们将覆盖包含我们要查找的条件的apply方法。因此,只要条件不成立(在我们的情况下,启用条件不成立),我们就会循环最多10秒,每500毫秒轮询一次(这是默认设置),直到apply方法返回true为止。
WebDriverWait wait = new WebDriverWait(driver,10);wait.until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver driver) { WebElement button = driver.findElement(By.xpath("xpath")); String enabled = button.getAttribute("aria-disabled"); if(enabled.equals("true")) return true; else return false; }});


