Python selenium WebdriverWait

Python selenium WebdriverWait

如何使用webdriverwait编写底层代码

x = False
    while not x:
        try:
            manage = driver.find_element_by_xpath(
                "/html/body/main/div/article[1]/div[4]/header/div[2]/div/div/a")
            manage.click()
            x = True
        except StaleElementReferenceException:

            x = False

#

所以,明确的方式是:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

element = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, "/html/body/main/div/article[1]/div[4]/header/div[2]/div/div/a")));

element.click();