How to locate an android element which is off-screen, dynamically generated, and has no name or contentDescription


#1

I’m encountering a real mess of a problem and can’t seem to find an answer anywhere.

I have an android application where a table of elements is populated dynamically and information is filled in by what the application receives from a server call. Due to this, I have to work with what appium sees and what the server populates, instead of being able to assign identifiers to the elements. The second part of this problem is that since the element is off screen, Appium cannot locate it, and when I (manually) scroll the device so the element is on screen, all of the xpaths are erased and redrawn, so I don’t have a static reference point to the element I want.

Ex:

<root>
    <linearlayout>
        <table>
           <el1>
           <el2>
           <el3>
           <el4>
           <el5>
           <el6>
           <el7>
           <el8>
           <el9>
          <el10>

The screen displays el1 - el5, but I need to find el6. However, when the screen scrolls, el6 displays in xpath as el1.

Can anyone help? This is driving me insane.


#2

It would be extremely helpful to see the actual XML of your table and table’s children. As you’ve found using indexing in your xpath is useless since that changes with each screen scroll. In my AUT the immediate table rows ( in your example) have no real data. The unique data I need to key from is contained in children inside each row, usually those have a common @resource-id and a unique @text attribute. So I have to queue off that. The annoying thing is the @resource-id is different on the table rows on every page of my app so I can’t easily code a common function to extract/find/etc. table rows.

I’m still trying to crack the case on this myself. You can read more on my adventures here in case there’s some helpful data for you:


#3

@alexf Hi, I know this is pretty old topic but am facing the exact same issue by any chance did you find the solution for it? it will be really helpful thanks