我正在尝试让Selenium等待页面加载后动态添加到DOM的元素.试过这个:
fluentWait.until(ExpectedConditions.presenceOfElement(By.id("elementId"));
Run Code Online (Sandbox Code Playgroud)
如果它有帮助,这里是fluentWait:
FluentWait fluentWait = new FluentWait<>(webDriver) {
.withTimeout(30, TimeUnit.SECONDS)
.pollingEvery(200, TimeUnit.MILLISECONDS);
}
Run Code Online (Sandbox Code Playgroud)
但它会抛出NoSuchElementException- 看起来像presenceOfElement期望元素存在,所以这是有缺陷的.这对于Selenium来说一定是面包和黄油,并且不想重新发明轮子......任何人都可以建议一个替代品,理想情况下不要自己动手Predicate吗?