硒中的隐式等待

问题描述 投票:0回答:1

我对如何在selenium中使用隐式等待感到非常困惑

driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(4, TimeUnit.SECONDS);

我经常看到有人把这两行代码写在一起。为什么我们需要

pageLoadTimeOut
线?我认为第一行就足够了。

我通过谷歌搜索了很多,但仍然很困惑

java selenium-webdriver wait implicit pageloadtimeout
1个回答
0
投票

看看 WebDriver.Timeouts

pageLoadTimeout(Duration duration)

设置抛出错误之前等待页面加载完成的时间。

implicitlyWait(Duration duration)

指定驱动程序在搜索未立即存在的元素时应等待的时间。

没有理由将这些写在多个地方,这是在

driver
一生中保留的一次设置。

您还应该注意,您正在使用已弃用的方法

implicitlyWait(long time, TimeUnit unit)
pageLoadTimeout(long time, TimeUnit unit)

© www.soinside.com 2019 - 2024. All rights reserved.