等待方式
- time.sleep()
- WebDriverWait
- implicitly_wait
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome()
driver.implicitly_wait(10)
driver.get('https://outlook.live.com/owa/#')
driver.find_element_by_css_selector('div > a.linkButtonSigninHeader:nth-child(4)').click()
try:
# inputEmail = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.NAME,'loginfmt')))
inputEmail = WebDriverWait(driver,10).until(lambda driver: driver.find_element_by_name('loginfmt'))
inputEmail.send_keys('1321312312')
except expression as identifier:
print('time out...')
# driver.find_element_by_name('loginfmt').send_keys('1234455')