Skip to content

Instantly share code, notes, and snippets.

@sayems
Created January 22, 2016 20:58
Show Gist options
  • Select an option

  • Save sayems/9c8b80aa8826f1adcd28 to your computer and use it in GitHub Desktop.

Select an option

Save sayems/9c8b80aa8826f1adcd28 to your computer and use it in GitHub Desktop.
How To Test For Disabled Elements
driver.get("http://the-internet.herokuapp.com");
driver.findElement(By.linkText("Dropdown")).click();
List<WebElement> dropdown=driver.findElements(By.xpath("//select[@id='dropdown']/option"));
for (int i = 0; i < dropdown.size(); i++) {
if(dropdown.get(i).getText()=="Please select an option")
{
//assert false will always expects false value.
//Here option is disabled so it will return false
Assert.assertFalse(dropdown.get(i).isEnabled());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment