1. Alert, first use the normal method to locate the button that triggers the Alert, and then
Alert alert = Driver.switchto (). alert (); Alert.accept ();
If the alert box is confirmed, it is OK to pop the alert box continuously, continue the same operation, pay attention to the delay ... Otherwise it could be too fast, wrong, pit.
Alert alert = Driver.switchto (). alert (); Alert.accept (); Thread.Sleep (+); alert = Driver.switchto (). alert (); Alert.accept ();
2. Confirm
Alert confirm = Driver.switchto (). alert (); String Text1 = Confirm.gettext (); Get text System.out.println (Text1) on confirm; Confirm.accept (); Close confirm
3. Prompt
Alert prompt = Driver.switchto (). alert ();
Prompt.sendkeys ("OK!!!!") Input value, if input is supported prompt.accept (); Close prompt
The essence of them is the same, Driver.switchto (). alert () This sentence can get the object of the Alert\confirm\prompt dialog box, and then use its method to manipulate it. The main methods of dialog operations are:
. GetText () gets its text value
. Accept () is equivalent to clicking on its "Confirm"
. Dismiss () is equivalent to clicking "Cancel" or cross-off the dialog box
. SendKeys () input value, this alert\confirm can not be used, will error.
Java Selenium-Several dialog box handling alert\confirm\prompt