These are the Following methods in Selenium are used in conditional and looping operations:-
isEnabled() method is used when you want to verify weather a certain element is enabled or not before executing a command.
WebElement txtbox-username = driver.findElement(By.id("username"));
if(txtbox-username.isEnabled()){
txtbox-username.sendkeys("example");
}
2.isDisplayed() method is used when you want to verify weather a certain element is displayed or not before
executing a command.
do{
//do something here
}while (driver.findElement(By.id("username")).isDisplayed() );
3.isSelected() method is used when you want to verity a certain checkbox,radio button or option in a drop- down box is selected.It doesnot work on other elements:-
//"one-way" and "two-way" are radio buttons
if(driver.findElement(By.id("one-way")).isSelected();
{
driver.findElement(By.id("two-way")).click();
}
1 Comment(s)