如何在Selenium中组合隐式和显式超时? [英] How to combine implicit and explicit timeouts in Selenium?
本文介绍了如何在Selenium中组合隐式和显式超时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用具有隐式超时的Selenium ChromeDriver:
I am using Selenium ChromeDriver with an implicit timeout:
_driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
在我的一项测试中,我想用一个明确的超时值来覆盖它.在读取属性之前,我明确地等待找到该元素:
In one of my tests I want to override this with an explicit timeout. Before reading a property I explicitely wait for the element to be found:
WebDriverWait wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(120));
wait.Until(d => d.FindElement(By.CssSelector("div.example")));
我希望这需要120秒才能尝试找到该元素,但是5秒钟后就会超时.
I would expect this to take 120s to try to find the element, but it times out after just 5 seconds.
推荐答案
查看全文