[Appium 2] FindElements with XPath returns the first element (fixed)


With xpath the android locator was returning a list of elements with Appium 1.x, but with Appium 2 it returns the FIRST element only.

@iOSXCUITFindBy(iOSNsPredicate = "name CONTAINS 'list_item'")
@AndroidFindBy(xpath = "//*[@view-tag = 'list_item']")
List<WebElement> sections;

The sections.size() is 1

When I change the strategy to NonXPath, it returns all elements

@iOSXCUITFindBy(iOSNsPredicate = "name CONTAINS 'list_item'")
@AndroidFindBy(tagName = "list_item")
List<WebElement> sections;

The sections.size() is 5

of course, the FindElements() behaves in the same way.

The only difference is xpath="//*[@view-tag='list_item']" vs tagName="list_item"

I couldn’t find a note about that in v7-to-v8-migration-guide.md.

I assume it has something to do with the XPath2. This link points to that but still it is not clear why my mentioned example doesn’t return the list of elements.

I noticed that with Appium Inspector the same XPath expression returns full list of elements.

Then I compared request lines of server logs from the test run and from the Appium Inspector’s session - they where the same.

So, the same request with XPath locator returns 1 element in tests, but returns full list in Appium Inspector.
Both are Appium 2 servers
Appium v2.0.0-beta.44 EspressoDriver (v2.10.0) without the issue
Appium v2.0.0-beta.46 EspressoDriver (v2.13.0) with the issue

Maybe it’s a capability or some other configuration issue.
Does anyone have a clue what it can be, I can’t find any related capability.


The issue was in EspressoDriver v2.13.0

It is fixed in EspressoDriver v2.13.3

appium driver uninstall espresso
appium driver install [email protected]
1 Like