I am learning Webdriver with JUnit by going through Alan Richardson's Selenium Simplified book and taking translating the exercises/tests from Selenium RC to Webdriver. So far, this has proven to be an excellent learning experience. But recently I have hit an issue, and cannot solve it despite extensive searching.
In Selenium RC there is a selenium.check command which will check a box if it is empty, or leave it if it is already checked. For example:
selenium.check("//input[@name=’checkboxes[]’ and @value=’cb3’]");
If you go to the target website (http://compendiumdev.co.uk/selenium/basic_html_form.html) you will see there are three check boxes, one of which is checked. I have written some pseudo-code but just can't get into making it work. Here is the pseudo-code:
isChecked = driver.findElement(By.xpath("//input[@type='checkbox']"));
if (isChecked = false){
check the box;
}else}
do nothing;
}
I know the boolean "isSelected()" should feature, but I don't know where to go beyond that. All my research has returned partial solutions, but nothing that gets close enough for me to take a leap of faith at the solution.
