Wait until element is not present

后端 未结 2 810
不知归路
不知归路 2021-01-04 18:52

I\'m using selenium in Python 2.7 and I have this code, but I\'m looking for a more efficient way to do this:

while True:
    try:
        element = WebDrive         


        
相关标签:
2条回答
  • 2021-01-04 19:01

    1) Use staleness_of from expected condition

    class staleness_of(object):
    """ Wait until an element is no longer attached to the DOM.
    element is the element to wait for.
    returns False if the element is still attached to the DOM, true otherwise.
    """
    

    2) WebDriverWait(driver, 10).until_not(...)

    0 讨论(0)
  • 2021-01-04 19:22
     element = WebDriverWait(driver, 10).until(
                EC.invisibility_of_element_located((By.ID, 'button'))
    

    you don't need to use while. it already waits for time that you present in WebDriverWait() function.

    0 讨论(0)
提交回复
热议问题