ITSourceCode.com

We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

How can we find if an element in 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

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked *

ITSourceCode.com © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!