Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When doing copyTextFrom for an index in a FlatList, the copied value seems to be unreliable #2283

Open
1 task done
davidcarboni opened this issue Feb 3, 2025 · 1 comment

Comments

@davidcarboni
Copy link

Is there an existing issue for this?

  • I have searched the existing issues and didn't find mine.

Steps to reproduce

I'm testing a behaviour where items in a list should move to the top of the list after being viewed.
To do this, my component assigns a testID to each item in the list according to its index ('client0', 'client1', 'client2', etc.)
On navigating back to the list, I copyTextFrom client0 to check the item that's at the top of the list.
Visually in the emulator I can see the item at the top of the list has the correct value, however the value of maestro.copiedText differs - it's often the value from what should be client1.

In fact, now I've done a few more runs, sometimes it fails on the first asserTrue so it seems like somehow it's seeing the testId at a different index than it's visually displayed on the screen (e.g. the copied text is requested from client0 but the value received is from the second item I can see on the screen, which should be client1).

Here are the steps from the test:

# Make sure clients move to the top of the list when viewed

- tapOn: ${output.clients.May.name + ' ' + output.clients.May.surname}
- back
- copyTextFrom:
    id: client0 # May should be at the top of the list after being viewed
- evalScript: ${console.log('Client0 name is ' + maestro.copiedText)} # <-- Sometimes displays the value from the second item, not the first
- assertTrue: ${maestro.copiedText === output.clients.May.name + ' ' + output.clients.May.surname} # <-- Test sometimes fails here

- tapOn: ${output.clients.June.name + ' ' + output.clients.June.surname}
- back
- copyTextFrom:
    id: client0 # June should now be at the top of the list after being viewed
- evalScript: ${console.log('Client0 name is ' + maestro.copiedText)} # <-- Displays the value from the second item, not the first
- assertTrue: ${maestro.copiedText === output.clients.June.name + ' ' + output.clients.June.surname} # <-- Test usually fails here

Image

Actual results

Here is the output I get. I've noticed the console log statements are repeated (or jumbled up if I print out multiple list indices) as displayed just before the failed step:

 ║    ✅   Tap on "May Smith"                                                     
 ║    ✅   Press back                                                                                     
 ║    ✅   Copy text from element with id: client0                                
 ║    ✅   Run ${console.log('Client0 name is ' + maestro.copiedText)}                                    
 ║         Log messages:                                                          
 ║           Client0 name is May Smith                                                                    
 ║    ✅   Assert that true is true                                               
 ║    ✅   Tap on "June Day"                                                                              
 ║    ✅   Press back                                                             
 ║    ✅   Copy text from element with id: client0                                
 ║    ✅   Run ${console.log('Client0 name is ' + maestro.copiedText)}            
 ║         Log messages:                                                          
 ║           Client0 name is May Smith                                            
 ║           Client0 name is May Smith                                            
 ║    ❌   Assert that false is true
 ║

Assertion is false: false is true

Expected results

I need to be able to retrieve the text of the first item in the list so that I can verify the behaviour of items moving to the top.
It seems like the testID based on the index in the list isn't working well with copyTextFrom.
I'm wondering if this could be abug and/or whether there's a different way to check an item's position in a list.

About app

Closed Source (apologies, I haven't extracted a working sample)
Cross-platform
React Native 0.76.6 / Expo 52.0.28

About environment

openjdk 21.0.5 2024-10-15
Ubuntu 24.10
x86_64

Logs

Logs

commands-(recent_client.yml).json


Maestro version

1.39.9

How did you install Maestro?

install script (https://get.maestro.mobile.dev)

Anything else?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant