Skip waiting for a website timer selenium Python

前端 未结 1 1128
北荒
北荒 2020-12-12 03:06

I\'m running Selenium in Python ide with geckodriver.

The site I\'m trying to open has a timer of 30 seconds that after this 30 seconds a button appears and I send a

相关标签:
1条回答
  • 2020-12-12 04:03

    As per your code trial you can remove the time.sleep(30) and induce WebDriverWait for the element to be clickable as follows :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    # lines of code
    WebDriverWait(driver, 30).until(EC.element_to_be_clickable((By.ID, "proceed"))).click()
    

    Note : Configure the WebDriverWait instance with the maximum time limit as per your usecase. The expected_conditions method element_to_be_clickable() will return the WebElement as soon as the element is visible and enabled such that you can click it.

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