gpt4 book ai didi

Selenium Webdriver 等待很长时间

转载 作者:行者123 更新时间:2023-12-04 22:05:59 27 4
gpt4 key购买 nike

我可以使用 Selenium Web Driver 等待很长时间吗?

即使我可以像下面那样设置隐式等待命令,它也不会等待我给出的时间。

 driver.manage().timeouts().implicitlyWait(5, TimeUnit.MINUTES);

这里有什么问题吗?

就我而言,我需要执行一个测试用例并等待 4 分钟,然后再执行下一个测试用例。

我在这里使用Java。

最佳答案

考虑到你需要等待一个特定的元素,我会在 ExplicitWait 的行中做一些事情,如下所示。

WebDriverWait wait = new WebDriverWait(driver, 300); // The int here is the maximum time in seconds the element can wait.
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("someId")));

在这种情况下,您可以使用任何您喜欢的 ExpectedConditions
也不必在某些非常特殊的情况下使用很长的等待时间。这个恕我直言是一个很好的做法。

关于Selenium Webdriver 等待很长时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14893781/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com