import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.UnhandledAlertException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class TrycatchUnderstand {
public WebDriver driver = new ChromeDriver();
@Test
public void tcu(){
//WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://mail.rediff.com/cgi-bin/login.cgi");
try{
driver.findElement(By.xpath("//input[@type='submit'][@name='proceed']")).click();
driver.findElement(By.xpath("//a[text()='Home']")).click();
driver.close();
}
catch(UnhandledAlertException uae){
System.out.println("Alert has ocured: "+uae);
Alert al = driver.switchTo().alert();
al.accept();
driver.switchTo().defaultContent();
}
finally{
driver.findElement(By.xpath("//a[text()='Home']")).click();
driver.close();
}
}
}
Try catch in Selenium
Tags
# SELENIUM
About Unknown
Soratemplates is a blogger resources site is a provider of high quality blogger template with premium looking layout and robust design. The main mission of templatesyard is to provide the best quality blogger templates.
SELENIUM
Labels:
SELENIUM
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment