I'm using the AppiumDriver and MobileElement java packages (I'm writing in Kotlin) to UI test an iOS app that already has tests written using XCUITest.
I need a function that behaves the same as XCUIElement.exists() acts in XCUITest. This would be a function that returns true if the UIElement in question is present on the screen regardless of whether it is visible/clickable. An example of this is a UI element embedded in a scrollview that's out of sight (not scrolled to). It's on the page, but it is not visible nor is it hittable.
Right now I have a scrollview with UI elements out of sight, that the program will hang waiting for their visibility, until I manually scroll the scrollview to bring them into view, which at that point will pass the tests.
I can confirm that MobileElement.->
isDisplayed()
(this behaves more like isHittable() than exists() from what I've seen)
isEnabled()
isSelected()
All do not do what I want, neither does anything along the lines of:
driver.findElements(By.xpath("value")).size() != 0
The above line seems to return true in the exact same cases as isDisplayed if I'm not mistaken.
EDIT: Some users have suggested that the elements may not exist yet due to lazy loading, and that being the reason why the
driver.findElements(By.xpath("value")).size() != 0
line does not work. In response to this I have added an image of the div representing the scrollview in the iOS app. The highlighted UI Element still cannot be found using until the user manually scrolls down to make it visible before the request times out.