maestro icon indicating copy to clipboard operation
maestro copied to clipboard

Command to copy text

Open ateslovan opened this issue 1 year ago • 1 comments

Would love to have the option to copy the text from a view so it can be checked against some other view. This would also bring in discussion a new assert - assertTextEquals - or something similar.

ateslovan avatar Sep 01 '22 12:09 ateslovan

That is doable and indeed makes sense - we will add this

dmitry-zaitsev avatar Sep 01 '22 13:09 dmitry-zaitsev

#403 Adds copy text from element and paste into text field. @ateslovan Does this resolve your issue?

ArthurSav avatar Nov 17 '22 13:11 ArthurSav

@ArthurSav Great news & addition! But I was thinking of something more 'complicated' when writing this request.

I'm thinking of a case where you have 2 screens:

  • One where you can add favourites
  • One where you can see favourites

The case I would test would sound something like: Add a favorite then make sure the favorite appears on favourites screen.

Using the getText method you could compare that the text of the favourite item from the first screen appears on the second screen - but I would also like an assertEquals method so that the test fails in case this isn't true.

so, in the end I think we would need:

  • getText method
  • a way to save the getText in a variable
  • an assert to compare two text values

Does it make sense?

ateslovan avatar Nov 25 '22 09:11 ateslovan

@ateslovan the next release of Maestro (1.16.0) will include some basic Javascript support that will make such usecase possible. The logic would then be something like this:

- copyTextFrom: "Field A"
- evalScript: ${output.fieldA = maestro.copiedText}
- copyTextFrom: "Field B"
- assertTrue: ${output.fieldA == maestro.copiedText}

dmitry-zaitsev avatar Nov 25 '22 10:11 dmitry-zaitsev

Awesome! I think that will do the job

ateslovan avatar Nov 25 '22 11:11 ateslovan

This is live now in Maestro 1.16.0

https://maestro.mobile.dev/advanced/javascript/access-element-text

dmitry-zaitsev avatar Nov 30 '22 15:11 dmitry-zaitsev

This issue has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar problem, please file a new issue. Make sure to follow the template and provide all the information necessary to reproduce the issue. Thank you for helping keep us our issue tracker clean!

github-actions[bot] avatar Jul 11 '24 17:07 github-actions[bot]