Wednesday, 11 September 2013

How to handle java script/error/exception alert using WebDriver

WebDriver would support handling js alerts using Alert interface.
         
          // Bring control on already opened alert
               Alert alert = driver.switchTo().alert();

          // Get the text/message of the alert or prompt
               alert.getText(); 
         
         // Click ok button of alert
              alert.accept();

         // Click Cancel button of alert
              alert.dismiss();

No comments:

Post a Comment