selenium的显性等待

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

capa = DesiredCapabilities.CHROME
capa["pageLoadStrategy"] = "none"

browser = webdriver.Chrome(desired_capabilities=capa)
browser.get('https://www.pixiv.net/')

locator = (By.LINK_TEXT, '立即注册')
wait = WebDriverWait(browser, 15)
button = wait.until(EC.element_to_be_clickable(locator))
browser.execute_script('window.stop()')
button.click()

你可能感兴趣的:(selenium的显性等待)