Showing posts with label radio button is selected. Show all posts
Showing posts with label radio button is selected. Show all posts

Monday, 17 November 2014

How to verify if button is Selected in Selenium Webdriver in Java?

How to verify if button is Selected in Selenium Webdriver in Java?
package com.snapdeal;
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;
public class TestIsSelected {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
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());
} finally {
driver.close();
}
}
}