Inspect array output limited to 4?

46 views
Skip to first unread message

sergey...@gmail.com

unread,
Jan 26, 2023, 5:30:17 PM1/26/23
to Automate
I'm trying to use the Inspect block to grab content from the screen (output of a search) to parse.  I need to get several different bits of data from each search results. The challenge I'm having is that the output of Inspect seem to be incomplete.

I'm dealing with content that has a bunch of android.widget.TextView elements nested inside an android.view.View element.  None of these have IDs, and the entire structure could be repeated N times, depending on the query that is passed to the application.  I can identify one of these textView elements by its text, and so I built an XPath expression to give me a Node-Set of the ancestors of my matching textView:

//ancestor::*[android.widge.TextView[@android:text='" ++ varVariable + "']]"

Result type is set to Node-Set.

This works, and I get back an array of these nodes.  But the output array only contains 4 elements, even though there are way more on the screen than 4.

My goal here is to iterate through the these structures returned by the application to extract the relevant bits of information to then go and act on.  Is there a bug or a built-in limit or am I doing something totally wrong?

Should I instead be trying to iterate and parse through this stuff by changing my XPath to extract only a single node and putting that inside a loop?

Thanks.

Henrik "The Developer" Lindqvist

unread,
Jan 26, 2023, 5:53:53 PM1/26/23
to Automate
There's no limit on the number of results, not unless the Java XPath engine (Xalan) has one.
You should probably put the ancestor:: axis at the end, to get every parent and grand parent of the matching TextViews, i.e.:
//android.widget.TextView[@android:text={varVariable;xpathEncode}]/ancestor::*

Sergey Polak

unread,
Jan 26, 2023, 6:53:43 PM1/26/23
to automa...@googlegroups.com
I don't need the grandparents and the rest. I really just need the TextView elements but I need to preserve their grouping, which is why I am taking the parent container. 

So if there's not supposed to be a limit, why am I only getting 4 results when there are more matches in the XML?


--
You received this message because you are subscribed to a topic in the Google Groups "Automate" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/automate-user/IlOSOiHxvTs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to automate-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/automate-user/cfd1e0c7-9c16-473b-8621-2de4656daddfn%40googlegroups.com.

Sergey Polak

unread,
Jan 27, 2023, 8:06:55 AM1/27/23
to automa...@googlegroups.com
I figured it out. Only the first 4 containers are visible on the screen. I have to scroll down to see more. I was assuming I would get the whole result set back. 

So what is more efficient - getting the array of nodes in one inspect call and parsing them for the 4-5 bits of information I need from each node, or making 4-5 separate inspect calls to get them?

Henrik "The Developer" Lindqvist

unread,
Jan 27, 2023, 8:11:14 AM1/27/23
to Automate
Fewer inspection calls is better.

Henrik "The Developer" Lindqvist

unread,
Jan 27, 2023, 8:18:09 AM1/27/23
to Automate
... i.e. one call and parsing.

Sergey Polak

unread,
Jan 27, 2023, 8:22:19 AM1/27/23
to automa...@googlegroups.com
Great, thanks for the quick responses. 

Reply all
Reply to author
Forward
0 new messages