简体   繁体   English

ExpectedConditions.InvisibilityOfElementLocated需要更多时间

[英]ExpectedConditions.InvisibilityOfElementLocated takes more time

I came across a situation where I need to wait until an element disappears (in firefox). 我遇到了一种情况,我需要等到元素消失(在Firefox中)。 So I tried different options but nothing worked so tried using 所以我尝试了不同的选择,但是没有任何作用

new WebDriverWait(Drivers._driverInstance, new TimeSpan(0, 0, 2)).Until(ExpectedConditions.InvisibilityOfElementLocated(locator));

This worked but it takes 26 seconds to run the test case. 这可行,但是运行测试用例需要26秒。 When I commented that sentence it took half of the time. 当我评论该句子时,花费了一半的时间。 Why does this particular method takes more time. 为什么此特定方法需要更多时间。 Though I mentioned only 2 seconds it's waiting for nearly 10 seconds. 尽管我只提到2秒钟,但它正在等待近10秒钟。 Why is it doing so? 为什么这样做呢? Is there a quicker way to wait until element disappears. 有没有一种更快的方法来等待元素消失。

Thanks. 谢谢。

If you have an implicit wait in your code before this explicit wait. 如果在此显式等待之前在代码中进行了隐式等待。 Remove the implicit wait and try. 删除隐式的等待,然后尝试。 Mixture of implicit and explicit wait could be causing this behaviour. 隐式等待和显式等待的混合可能会导致这种行为。

Check this out and look at the accepted answer -- Clarification on the cause of mixing Implicit and Explicit waits of Selenium doc 检查一下并查看可接受的答案- 澄清硒文档的隐式和显式等待混合的原因

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM