Android – use espresso to find multiple elements in a web view

I am testing a hybrid application, where each view has a web view. In one of the web views, I have a list of elements with the same attributes. They have the same XPath locator, as shown below:

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

I want to create a list of these elements and iterate over them, calculate them, and get their properties

In the document, I found two similar methods:

findElement(locator, value)

and

findMultipleElements(locator, value)

Although I don't know how to use it at all. I tried to find an example of it, but I didn't succeed

Can someone help me?

resolvent:

Can you try this? Because you should be concerned about elementreference, you can use a simple for / foreach statement to iterate over the LSIT returned from findmultipleelements:

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
}

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>