Find multiple items in an espresso web view

I am testing a hybrid application where each view has a web view.
In one of these web views, I have a list of items with the same attribute. They have the same xpath locator, something like:

//h4[contains(@data-role, 'product-name')]

I want to create a list of these elements and iterate over them, count them, get their attributes.

In the documentation, I found two similar methods:

findElement(locator, value)

and

findMultipleElements(locator, value)

Although it is completely incomprehensible to me how to use it. I tried to find examples, but without success.

Can anyone help me with this?

+4
source share
1 answer

- ? ElementReference, lsit, findMultipleElements, for/foreach:

yourList = findMultipleElements(locator, value);
yourList.size(); //this will get you the count of found elements with that locator
for(Atom<ElementReference> item : yourList ){
    item.getAttribute...
    //and whatever you want
}
0

Source: https://habr.com/ru/post/1655292/


All Articles