java + selenium + new-- operation of JavaScript shells 3 summarizes comparative block

Introducing package: import org.openqa.selenium.Alert;

 

 

The alert box shells js


Alert alert = driver.switchTo () alert ();. // get the object and create alert

alert.getText (); // get the text pop-up box

alert.accept (); // Click the OK button in the pop-up box above

 

 


========================================================================

 

 

js confirm the elastic block

 


Alert alert = driver.switchTo () alert ();. // get the object and create alert

alert.getText (); // get the text pop-up box

alert.accept (); // Click the OK button in the pop-up box above

alert.dismiss (); // Click the pop-up box above the Cancel button

 

 

 

========================================================================

 

 


js the prompt box shells

 


Alert alert = driver.switchTo () alert ();. // get the object and create alert

alert.getText (); // get the text pop-up box

alert.sendKeys ( "............"); // typing

alert.accept (); // Click the OK button in the pop-up box above

alert.dismiss (); // Click the pop-up box above the Cancel button

Guess you like

Origin www.cnblogs.com/xiaobaibailongma/p/12289640.html