我有以下代码:
WebDriverWait wait;
....
WebElement widget=webDriver.findElement(by);
WebElement el = wait.until(ExpectedConditions.elementToBeClickable(by));
我也尝试过ExpectedConditions.visibilityOfElementLocated和presenceOfElementLocated 我每次都得到相同的结果,click()发生但是太快了,它没有注册。如果我在点击之前使用Thread.sleep(),那么它按预期工作。这似乎是一个可怕的解决方案,所以我正在寻找其他的东西。我能想到的最好的就是循环:
while(!conditionThatIsTrueWhenClickHappens) {
el.click();
}
非常感谢任何建议,谢谢。