How can handle unexpected alert exception in Selenium Webdriver using java

 import java.util.concurrent.TimeUnit;  
 import org.openqa.selenium.Alert;  
 import org.openqa.selenium.NoAlertPresentException;  
 import org.openqa.selenium.UnhandledAlertException;  
 import org.openqa.selenium.WebDriver;  
 import org.openqa.selenium.firefox.FirefoxDriver;  
 public class Unexpectedalert {  
   public static void main(String[] args) {  
     WebDriver driver;  
     // creat firefox driver object    
     driver = new FirefoxDriver();  
     //Maximize browser window    
     driver.manage().window().maximize();  
     //Go to URL    
     driver.get("http://localhost:80/ideascalechallenge");  
     //Set timeout   
     driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 

 
 // handle Alert Exception  
     try {  
 // trigger unexpected alter event  
       driver.get("http://localhost:80/ideascalechallenge/a/idea?templateId=0");  
     } catch (UnhandledAlertException f) {  
       try {  
         Alert alert = driver.switchTo().alert();  
         String alertText = alert.getText();  
         System.out.println("Alert data: " + alertText);  
         alert.accept();  
         //or  depend event
         // alert.dismiss();  
       } catch (NoAlertPresentException e) {  
         e.printStackTrace();  
       }  
     }
  
   }  
 }  

1 comment:

  1. Hiro Mia: How Can Handle Unexpected Alert Exception In Selenium Webdriver Using Java >>>>> Download Now

    >>>>> Download Full

    Hiro Mia: How Can Handle Unexpected Alert Exception In Selenium Webdriver Using Java >>>>> Download LINK

    >>>>> Download Now

    Hiro Mia: How Can Handle Unexpected Alert Exception In Selenium Webdriver Using Java >>>>> Download Full

    >>>>> Download LINK la

    ReplyDelete