我知道Java有几种等待
隐式等待-
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS)
显式等待-
WebDriverWait wait = new WebDriverWait(driver, explicitWaitSec);
wait.until(ExpectedConditions.elementToBeClickable(element));
流畅等待-
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(30, TimeUnit.SECONDS)
.pollingEvery(5, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class);
,但我很困惑哪些等待和预期条件最接近 Robot Framework 中的 Wait Until Page Contains
关键字?
最佳答案
没有直接模拟,这是在 Robot Framework 中明确开发的功能。
同时可以用ExpectedCondition的presenceOfElementLocated()来实现具有明确/流畅的等待(后者只是第一个的更可定制版本,顺便说一句)。
对于定位器,使用这个 xpath:
//*[contains(., "Your Text Here")]
这就是Robotf Framework actually does ,我必须承认非常聪明。
关于java - Java中机器人框架 "Wait Until Page Contains"的等效ExpectedCondition是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54683989/