/** * Selenium v2: Un/Check radio buttons and check boxes. * It is assumed that Firefox is installed on your computer. * @Author: Xuan Ngo */ import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; public class CheckExample2 { public static void main(String[] args) { // All actions will be applied to Firefox. WebDriver oWebDriver = new FirefoxDriver(); // Open the webpage. oWebDriver.get("http://openwritings.net/sites/default/files/radio_checkbox.html"); // Radio Button: Check Monday using XPATH locator. WebElement oRadioBtn = oWebDriver.findElement(By.xpath("//input[@value='Mon']")); oRadioBtn.click(); // Checkbox: Uncheck Apple using CSS selector. WebElement oCheckBoxApple = oWebDriver.findElement(By.cssSelector("input[name='apple']")); // 2010-06-01: IE Driver doesn't support cssSelector yet. oCheckBoxApple.click(); // Checkbox: Check Orange using CSS selector. WebElement oCheckBoxOrange = oWebDriver.findElement(By.cssSelector("input[name='orange']")); // 2010-06-01: IE Driver doesn't support cssSelector yet. oCheckBoxOrange.click(); pause(10000); // Pause so that you can see the results. // Close the browser. oWebDriver.close(); } /** * Pause for X milliseconds. * @param iTimeInMillis */ public static void pause(final int iTimeInMillis) { try { Thread.sleep(iTimeInMillis); } catch(InterruptedException ex) { System.out.println(ex.getMessage()); } } }
Friday, 12 July 2013
Check radio buttons and checkboxes
Subscribe to:
Post Comments (Atom)
Angular JS Protractor Installation process - Tutorial Part 1
Protractor, formally known as E2E testing framework, is an open source functional automation framework designed spe...
-
In this article we are going to see the functions for keyboard's keypass key events. To find an element we use driver.FindElement(...
-
Using webdriver sometimes we need to run javascript code dircetly from our script. In one of the previous post we have discussed ho...
-
List<webElement> pagination =driver.findElemnts(By.xpath("//div[@class='nav-pages']//a")); // checkif pagination l...
No comments:
Post a Comment