'driver.findElements' doesn't return elements which are out of viewport

appium 1.6.3.
physical iphone 6
ios 10.0.2

I faced strange behaviour of appium. When i performed driver.findElements(MobileBy.xpath("…")) from java code then I receive 0 elements. I tried to delay searching by precending findElements with Thread.sleep(10000). It didn’t help.
Curious is that if I look for elements using Appium GUI Inspector then I am able to find element even if it is outside of the viewport.
I experimented with different xpaths ex.

Im asking because I want to implement method to check if element is present on certain mobile screen. This element may be placed in the last row of table which is out of the viewport.

Thanks in advance!

try the following the following method
public static void iOSScroll(AppiumDriver driver, string direction)
{
Dictionary<string, string> scrollObject = new Dictionary<string, string>();
scrollObject.Add(“direction”, direction);
((IJavaScriptExecutor)driver).ExecuteScript(“mobile: scroll”, scrollObject);
}

The element dont have to be visible.I dont need to scroll into it. What I want to know is that it is present on the screen even if it is outside of the viewport. Any ideas?

1 Like