selenium等待元素出现和代码抛出异常继续执行
1.隐式等待:
(1)全局的设定
(2)后面所有的选择元素的代码都不需要单独的指定周期性等待了
(3)driver.imlicitly_wait(10)
2.显示等待:
(1)为一个操作页面专门指定的时间
(2) from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
ele = WebDriverWait(driver,60)
until(EC.presence_of_element_located((By.ID,'username')))
3.抛出异常继续执行:
try:
ele = driver.find_element_by_id('')
print()
except:
print('exception happend')