Selenium - Wait until element is NOT visible

后端 未结 10 2085
生来不讨喜
生来不讨喜 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:00

    Yes, you can create your own ExpectedCondition, just revert visible to not visible.

    Here is how to do it in python:

    from selenium.webdriver.support.expected_conditions import _element_if_visible
    
    class invisibility_of(object):
    
        def __init__(self, element):
            self.element = element
    
        def __call__(self, ignored):
            return not _element_if_visible(self.element)
    

    and how to use it:

    wait = WebDriverWait(browser, 10)
    wait.until(invisibility_of(elem))
    

提交回复
热议问题