Selenium 等待
类型 |
使用方法 |
原理 |
适用场景 |
|
|
|
|
|
|
|
|
|
|
|
|
from selenium import webdriver import time from selenium.webdriver.common.by import By def implicitly_method(): driver = webdriver.Edge() url = 'https://www.cnblogs.com/' driver.get(url) driver.implicitly_wait(2) driver.find_element(By.LINK_TEXT,"Oracle与MySQL的差异和对比").click() time.sleep(3) if __name__ == '__main__': implicitly_method()
from selenium import webdriver import time from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC def implicitly_method(): driver = webdriver.Edge() url = 'https://www.cnblogs.com/' driver.get(url) WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.LINK_TEXT, "Oracle与MySQL的差异和对比"))) driver.find_element(By.LINK_TEXT,"Oracle与MySQL的差异和对比").click() time.sleep(3) if __name__ == '__main__': implicitly_method()