maestro icon indicating copy to clipboard operation
maestro copied to clipboard

Access device clipboard?

Open NBorba opened this issue 2 years ago • 0 comments

I have a scenario where I want to validate if a value that was just copied to the clipboard is the same as shown on the screen.

Example:

# Tap on copy button for data that is shown on the screen
- tapOn: "Copy"
# Value should now be in the clipboard
# Store the actual value we are showing to the user
- copyTextFrom: 
    id: "my-input"
# Assert that the value in the clipboard is the same as the one the user sees
- assertTrue: ${maestro.clipboard == maestro.copiedText}  

Does something like this make sense?

Currently, I'm doing a very impractical and hacky workaround, which is to add both values to an input field:

  • The first, by long pressing the field and pressing "paste", which will use the device's clipboard.
  • A separator (space, special characters, etc...)
  • The second, by using the pasteText command, which uses the value stored from the copyTextFrom.

Then, I copy the whole value from the input and split the string in js, by doing something like:

var text = maestro.copiedText;
var words = text.split(" || ");
output.result = words[0] == words[1];

By doing this whole process, I can compare if the clipboard data is correct, but as you can see this does not scale well, is a lot of code for a basic process, and requires an actual screen with an input field to paste both values into.

It would be very useful for Maestro to provide access to that information.

Thank you for reading!

NBorba avatar Feb 22 '23 22:02 NBorba