How to check and uncheck checkbox with selenium webdriver

Selenium Webdriver checkbox checked n unchecked script

package selenium_examples;

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 spicejet_example {

public static void main(String[] args) {

WebDriver driver = new FirefoxDriver();



   WebElement we = driver.findElement("AvailabilitySearchInputLoginView_Defense"));;




Output of the above script:-


Above script checks Checkbox,Indian armed forces personnel in website and unchecks the same checkbox.

isSelected() method verifies whether the element is selected or not.Used for checkboxes, options in a select and radio buttons.
It returns true if the element is currently selected or checked, false otherwise.

No comments:

Related Posts Plugin for WordPress, Blogger...