selenium自动化confirm弹框解决方案

弹框主要有以下:

  1. alert弹框

  1. confirm弹框,alert弹框加了取消按钮

  1. prompt弹框,alert弹框加了确认内容

今天主要解决confirm弹框,弹框

selenium自动化confirm弹框解决方案_第1张图片

方法一

options=webdriver.IeOptions()

options.ignore_protected_mode_settings=True

options.binary_location=r'D:\Program Files\360\360se6\Application\360se.exe'

driver=webdriver.Ie(executable_path="D:\Python\Python36\IEDriverServer.exe",options=options)

driver.get("http://10.0.0.1:9080/")

confirmAlert=driver.switch_to_alert();

confirmAlert.accept()#点击确定

confirmAlert.dismiss()#点击取消

方法二:

from selenium.webdriver.common.alert import Alert

options=webdriver.IeOptions()

options.ignore_protected_mode_settings=True

options.binary_location=r'D:\Program Files\360\360se6\Application\360se.exe'

driver=webdriver.Ie(executable_path="D:\Python\Python36\IEDriverServer.exe",options=options)

driver.get("http://10.0.0.1:9080/")

confirmAlert=Alert(driver)

confirmAlert.dismiss()#点击确定

#confirmAlert.accept()#点击取消

你可能感兴趣的:(selenium,python自动化,selenium,自动化)