selenium--|警告框处理

#####################################################
## 警告框处理
#####################################################

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

b = webdriver.Chrome()
b.implicitly_wait(10)
b.get('file:///E:/ZM20190316/2.Selenium/TestDemo/alertDemo/promptTest.htm')
b.maximize_window()

b.find_element_by_name('b1').click()

WebDriverWait(b,30,0.5).until(EC.alert_is_present())

print(b.switch_to.alert.text)
b.switch_to.alert.send_keys('西易欧全栈自动化测试')
#确认警告框
b.switch_to.alert.accept()
#关闭警告框
b.switch_to.alert.dismiss()

sleep(3)
b.quit()

 

posted @ 2019-06-12 18:10  い昔阳ゾ  阅读(110)  评论(0编辑  收藏  举报