Selenium - Wait until element is NOT visible

后端 未结 10 2089
生来不讨喜
生来不讨喜 2021-02-02 07:29

In the code below, I attempt to wait until an element is visible:

var wait = new WebDriverWait(Driver.Instance, TimeSpan.FromSeconds(10));
wait.Until(ExpectedCon         


        
10条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-02 08:18

    var wait = new WebDriverWait(Driver.Instance, TimeSpan.FromSeconds(10));
    wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("processing")));
    

    The idea is to wait until element is not visible. First line sets wait time that element has to disappear; here it's 10 seconds. Second line uses selenium to check if condition "invisibilityofElementLocated" is met. Element is found by its id as in topic case, that is id="processing". If element doesn't disappear in the requested period of time, a Timeout exception will be raised and the test will fail.

提交回复
热议问题