//Exception Handling with example in selenium
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class TestIsSelected {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
//Exception handling ie., using Try Catch block
try {
driver.get(“https://register.rediff.com/register/register.php?FormName=user_details”);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
WebElement e = driver.findElement(By.xpath(“//input[@type='radio']“));
boolean actual = e.isSelected();
if (actual) {
System.out.println(“Button is Selected”);
} else {
System.out.println(“Button is not Selected”);
try {
driver.get(“https://register.rediff.com/register/register.php?FormName=user_details”);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
WebElement e = driver.findElement(By.xpath(“//input[@type='radio']“));
boolean actual = e.isSelected();
if (actual) {
System.out.println(“Button is Selected”);
} else {
System.out.println(“Button is not Selected”);
}
} catch (Exception ex) {
System.out.println(“Exception” + ex.getMessage());
System.out.println(“Exception” + ex.getMessage());
} finally {
driver.close();
}
}
}
driver.close();
}
}
}
No comments:
Post a Comment