I just want to check if the element is present on the page or not?
I am confused with what can be used. What is feasible to use isDisplayed() or isPresent()?
What is the difference between these two?
I just want to check if the element is present on the page or not?
I am confused with what can be used. What is feasible to use isDisplayed() or isPresent()?
What is the difference between these two?
isPresentfunctionisDisplayedreturnsTrueonly if the element is displayed on the webpage and is actually visible.If you just want to check if the element is present then you can do one of the following:
findElementinside a try/catch block. If it goes insidecatchwithNoSuchElementExceptionthen the element is not present.findElementsinstead offindElementand if length of the list returned byfindElementsis zero, then the element is not present.