0
List<WebElement> btnlogoutprofilelist = PageFactory.getInstance().getU4FLoginPage().getBtnlogoutprofilelist();
System.out.println(btnlogoutprofilelist.size());

Above method I am using to check element visibility. but it is taking more time to get list of element. nearly it is one min to get List of element.

I tried isDisplayed() but that element not present in the DOM due to that it is returning nosuchelement exception. isDisplayed method not returning boolean value. Please guide me to check element visibility in Selenium Java

Prophet
  • 32,350
  • 22
  • 54
  • 79
  • 1
    Does this answer your question? [How to check if an element is visible with WebDriver](https://stackoverflow.com/questions/2646195/how-to-check-if-an-element-is-visible-with-webdriver) – Ricky Sixx Aug 03 '21 at 16:50
  • Yes, i got the information, Thanks – Balaji JLN Aug 04 '21 at 12:42

1 Answers1

0

As I see from your question, you actually want to validate element presence, not visibility.
To do so the simplest way is to use something like driver.findElements(By.xpath(the_xpath_locator)).isEmpty();
In case element no present on the page the list will be empty.
Otherwise non-empty.

Prophet
  • 32,350
  • 22
  • 54
  • 79