Unit testing WebDriver.click()不工作,即使设置了ExpectedConditions

Unit testing WebDriver.click()不工作,即使设置了ExpectedConditions,unit-testing,selenium,junit,Unit Testing,Selenium,Junit,我有以下代码: WebDriverWait wait; .... WebElement widget=webDriver.findElement(by); WebElement el = wait.until(ExpectedConditions.elementToBeClickable(by)); 我还尝试了预期条件。元素定位的可视性和元素定位的存在性 每次我都会得到相同的结果,click()发生得太快,而且没有注册。如果我在单击之前使用Thread.sleep(),那么它将按预期工作。这

我有以下代码:

WebDriverWait wait;
....

WebElement widget=webDriver.findElement(by);
WebElement el = wait.until(ExpectedConditions.elementToBeClickable(by));
我还尝试了预期条件。元素定位的可视性和元素定位的存在性 每次我都会得到相同的结果,click()发生得太快,而且没有注册。如果我在单击之前使用Thread.sleep(),那么它将按预期工作。这似乎是一个可怕的解决方案,所以我正在寻找其他解决方案。我能想到的最好的方法就是这样一个循环:

while(!conditionThatIsTrueWhenClickHappens) {
     el.click();
}

非常感谢您的任何建议。

您点击的是什么?我们能看到html吗?@Dax,如果你让我们了解html的外观,我们可能会更快地提供帮助。