首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用Selenide等待HTML元素全局出现?

如何使用Selenide等待HTML元素全局出现?
EN

Stack Overflow用户
提问于 2020-01-16 10:33:47
回答 3查看 336关注 0票数 1

我们有很多由Selenide编写的e2e测试。为了避免在测试服务器中测试失败,我希望selenide等待html元素出现。

我知道一些脚本,比如wait.until(...)。但是,我不想修复所有的测试代码。

Selenide有没有全局开关或设置?(详细地说,我希望让cssselector等待)

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2020-01-17 13:33:01

我的问题由this post解决

代码语言:javascript
复制
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.

我认为隐式等待时间几乎是我所期望的全局开关。

票数 0
EN

Stack Overflow用户

发布于 2020-02-27 14:10:55

在执行任何操作之前,selenide提供了查找条件的方法。$("By Locator").shouldBe(Condition."Desired Condition").

票数 0
EN

Stack Overflow用户

发布于 2021-10-28 18:50:46

这个问题我可能会迟到。但是对于那些在selenide等待中仍然需要帮助的人来说,我的答案可能仍然是有帮助的。

对于selenium,如果你有这样的等待方法:

代码语言:javascript
复制
element = (new WebDriverWait(driver, <timeOutForElement>))
  .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(<cssSelector>)));

您可以使用element = $(<cssSelector>).should(exist);在Selenide中执行相同的操作

代码语言:javascript
复制
element = (new WebDriverWait(driver, <timeOutForElement>))
  .until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(<cssSelector>)));

我们就用element = $(<cssSelector>).shouldBe(visible);

参考页面Here

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59762277

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档