Click check box using selenium FirefoxDriver - Java HTML

Java examples for HTML:selenium

Description

Click check box using selenium FirefoxDriver

Demo Code

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.By;

import java.net.URL;

public class Main {

    public static void main(String[] args) throws Exception {

        WebDriver driver = new FirefoxDriver();

        driver.get("http://your server/training-test-page/");

        driver.findElement(By.id("comments")).sendKeys(
                "Nice page you got here");

        int i = 0;
        while (i != 10) {

            driver.findElement(By.id("unchecked_checkbox")).click();
            driver.findElement(By.id("checked_checkbox")).click();
            i++;/*from  w  ww .ja  va  2  s  .  co m*/
        }

        driver.findElement(By.id("submit")).click();

        driver.quit();
    }
}

Related Tutorials