Quality Testing

Quality is delighting customers

How to verify checkbox present on webpage or not using Selenium Webdriver?

Hello,

In a web page:

  • 1st case: if we select A, should show checkbox on web page
  • 2nd case: if we select B, shouldn't show checkbox on webpage

How to verify checkbox present on webpage or not using Selenium Webdriver?

Please help me .

Views: 435

Reply to This

Replies to This Discussion

case select a

public static boolean isElementsPresent(WebDriver driver, By by){
long endTime=System.currentTimeMillis() + waitTime;
while (System.currentTimeMillis() < endTime) {
try{
if(driver.findElements(by).size() > 0){return true; }
}catch(Exception e){}
}// end while
return false;
}
}
verify it should return true

case2 ::
it should return false

Hi

You can use testing experts code snippet for checking whether the checkbox is available or not then if there is count in the variable numberofBoxes that shows check boxes are available in the webpage

if (List<WebElement> boxes = driver.findElements(By.className("checkbox")==True");
int numberOfBoxes = boxes.length();
System.out.println(Its the Checkbox);
}
Else{
System.out.println(Not a Checkbox);
}

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2019   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service