Selenium3 + python automated alert box 007

Alert box

alert = driver.switch_to.alert

alert.text()

alert.accpet()

alert.dismiss()

# 导selenium包
from selenium import webdriver
from time import sleep

# Instantiated browser object 
Driver = webdriver.Chrome ()
 # define URL 
URL = ' D: \\ PyCharm \\ 05 \\ lebohtml OF -007-Selenium conventional positioning methods Register Automation \\ html \\ a.html ' 
# open the URL 
driver.get (URL)
 # click 
driver.find_element_by_id ( ' Alerta ' ) .click ()
 # appears playing block 
BTN = driver.switch_to_alert ()
SLEEP ( 3 )
 # get text on the button 
Print (btn.text)
 # call method - to determine 
btn.accept ()
driver.find_element_by_id ( ' userA ' ) .send_keys ( ' ADMIN ' )
 # wait 3 seconds 
SLEEP (. 3 )
 # close the browser 
driver.quit ()
Alert box

 

Guess you like

Origin www.cnblogs.com/liunaixu/p/11081908.html