How can we Find if an Element is Displayed on the Screen

0
37

This tutorial is all about how to find if an element is displayed on the screen.
Web Application has got so much diversity. So testing a web application is a challenges that too by using an automation tool. Few element become visible immediately while others takes time to load. So automated test fails sometime.
WebDriver provides the user following methods to check the visibility of the web elements. These web elements can be buttons, drop boxes, checkboxes, radio buttons, labels etc.

 

1.isDisplayed()
2.isSelected()
3.isEnabled()

Syntax:

  1. isDisplayed():
  2. boolean buttonPresence = driver.findElement(By.id(“myid”)).isDisplayed();
  3.  
  4. isSelected():
  5. boolean buttonSelected = driver.findElement(By.id(“myid”)).isDisplayed();
  6.  
  7. isEnabled():
  8. boolean searchIconEnabled = driver.findElement(By.id(“myid”)).isEnabled();
Facebook Comments
(Visited 42 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here