用显式等待替换隐式等待(selenium webdriver& java) [英] Replace implicit wait with explicit wait (selenium webdriver & java)

查看:192
本文介绍了用显式等待替换隐式等待(selenium webdriver& java)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何用明确的等待替换此隐式等待?

How can I replace this implicit wait with an explicit one?


driver = new ChromeDriver(功能);

driver = new ChromeDriver(capabilities);

driver.manage() .deleteAllCookies();

driver.manage().deleteAllCookies();

driver.manage()。timeouts()。implicitlyWait(10,TimeUnit.SECONDS);

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

这在Before Method中使用。我能够替换代码中的所有Thread.sleep(),但我不知道该怎么做。

This is used in the Before Method. I was able to replace all the Thread.sleep()'s in the code, but I'm not sure what do to for this one.

推荐答案

隐式等待是在驱动程序初始化之后定义的驱动程序生命周期,它设置驱动程序的最大时间来查看敌人 WebElement

Implicit wait is defined once right after the driver initialization for the driver life time, and it sets the maximum amount of time for the driver to look foe WebElement.

显式等待用于等待 WebElement 处于克制状态的给定时间,并且每次等待满足条件时都需要使用。

Explicit wait is used to wait up to the given amount of time for the WebElement to be in cretin condition, and need to be used each time you are waiting for condition to met.

你不能用显式等待替换隐式等待定义,因为它们是不同的东西在这一点上没有条件等待。

You can't "replace" the implicit wait definition with explicit wait, as they are different thing and there is no condition to wait for in this point.

这篇关于用显式等待替换隐式等待(selenium webdriver& java)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆