我们有很多由Selenide编写的e2e测试。为了避免在测试服务器中测试失败,我希望selenide等待html元素出现。
我知道一些脚本,比如wait.until(...)。但是,我不想修复所有的测试代码。
Selenide有没有全局开关或设置?(详细地说,我希望让cssselector等待)
发布于 2020-01-17 13:33:01
我的问题由this post解决
Implicit Wait is the way to configure the WebDriver instance to poll the HTML DOM (DOM Tree)
for a configured amount of time when it tries to find an element
or find a group/collection of elements if they are not immediately available.
As per the current W3C specification the default time is configured to 0.
We can configure the time for the Implicit Wait any where within our script/program and can reconfigure it as per our necessity.
Once we set Implicit Wait it will be valid for the lifetime of the WebDriver instance.我认为隐式等待时间几乎是我所期望的全局开关。
发布于 2020-02-27 14:10:55
在执行任何操作之前,selenide提供了查找条件的方法。$("By Locator").shouldBe(Condition."Desired Condition").
发布于 2021-10-28 18:50:46
这个问题我可能会迟到。但是对于那些在selenide等待中仍然需要帮助的人来说,我的答案可能仍然是有帮助的。
对于selenium,如果你有这样的等待方法:
element = (new WebDriverWait(driver, <timeOutForElement>))
.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(<cssSelector>)));您可以使用element = $(<cssSelector>).should(exist);在Selenide中执行相同的操作
为
element = (new WebDriverWait(driver, <timeOutForElement>))
.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(<cssSelector>)));我们就用element = $(<cssSelector>).shouldBe(visible);吧
参考页面Here。
https://stackoverflow.com/questions/59762277
复制相似问题