我遇到了一种情况,我需要等到元素消失(在 Firefox 中)。所以我尝试了不同的选择,但没有任何效果所以尝试使用
new WebDriverWait(Drivers._driverInstance, new TimeSpan(0, 0, 2)).Until(ExpectedConditions.InvisibilityOfElementLocated(locator));
这有效,但运行测试用例需要 26 秒。当我评论那句话时,它花了一半的时间。为什么这种特殊方法需要更多时间。虽然我只提到了 2 秒,但它等待了将近 10 秒。它为什么这样做?有没有更快的方法来等待元素消失。
谢谢。
最佳答案
如果在显式等待之前您的代码中有隐式等待。删除隐式等待并尝试。隐式和显式等待的混合可能导致此行为。
检查一下并查看已接受的答案 -- Clarification on the cause of mixing Implicit and Explicit waits of Selenium doc
关于c# - ExpectedConditions.InvisibilityOfElementLocated 需要更多时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40511642/