How to check does element is present(exist)?

I need to check if there is any element before any action is taken. I.g. If I do not enter required fields, the text “required field” must appear below the field. I see that Appium has a method isDisplayed(), but this method only works if the element is already displayed.

error text is normally some kind of element. it is left just check that this element exist when error expected and does not exist when no error expected.

I just need to test visibility. If Appium doesn’t have the solution, does Selenium has?

first check that element exist. if it exists then you can check if it visible.

isDisplayed() method only check does it displayed on screen, it ignores hidden elements.

if el does not exist -> el.isDisplayed() = NullPointerException