Python自动化测试,弹框警告的处理方法

Python自动化测试,弹框警告的处理方法:switch_to_alert()

from selenium import webdriver
from time import sleep

driver=webdriver.Firefox()
driver.get('https://www.baidu.com/')

driver.find_element_by_link_text('设置').click()
driver.find_element_by_link_text('搜索设置').click()

driver.find_element_by_id('sh_2').click()
#driver.find_element_by_css_selector('[for="sh_2"]').click()
driver.find_element_by_class_name('prefpanelgo').click()

alert=driver.switch_to_alert()
alert.accept()
sleep(3)
driver.quit()

你可能感兴趣的:(Python+selenium)