How can you find if an element in displayed on the screen using Selenium?

WebDriver facilitates the user with the following methods to check the visibility of the web elements. These web elements can be buttons, dropdown, checkboxes, radio buttons, labels etc.

  • isDisplayed()
  • isSelected()
  • isEnabled()

Example:

boolean buttonPresence = driver.findElement(By.id("")).isDisplayed();
boolean buttonSelected = driver.findElement(By.id("")).isSelected();
boolean searchIconEnabled = driver.findElement(By.id("")).isEnabled();