The process of selenium balloon (alert, confirm and prompt)

selenium automatic testing process, may pop up some of the JavaScript  generated alert, confirm and prompt, how to deal with these tips box it?

First, the introduction prompt box

(1) alter prompt box, only an OK button

(2) confirm the prompt box, there are OK and Cancel buttons

(3) prompt message box may enter text

Usage:
switch_to_alert () method to locate alert / confirm / prompt. Then use text / accept / dismiss / send_keys be needed to do gymnastics.

1. driver.switch_to_alert (). Text # Get the text message alert box 
2. driver.switch_to_alert (). Accept () # accept message box (OK) 
3.switch_to_alert (). Dismiss () # cancel 
4. driver.switch_to_alert () ( "hello") # input value .send_keys

 

Guess you like

Origin blog.csdn.net/qq_35577990/article/details/89857485