如何等待 HTML 元素与 Selenide 全局出现?

How to wait HTML element appear globally with Selenide?

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

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

Selenide 是否有任何全局开关或设置? (详细希望选项制作cssselector等待)

我的问题已由 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.

我认为隐式等待时间几乎是我预期的全局切换。

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

这个问题我可能来晚了。但是对于硒化等待仍然需要帮助的任何人,我的回答可能仍然有帮助。

对于 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