mobile-dev-inc / maestro

Painless Mobile UI Automation
https://maestro.mobile.dev/
Apache License 2.0
5.86k stars 280 forks source link

Add new `copyText` command #2029

Open moxorama opened 2 months ago

moxorama commented 2 months ago

Use case

There is a lot of issues with input flakiness, but there is no need to test input each time We can just paste text in input, and I hope it will be more stable

https://github.com/mobile-dev-inc/maestro/issues/1225

Proposal

There is the pasteText command in maestro, so adding copyText with string argument will give us more complete api.

Instead of

- tapOn:
    id: email-feild

- inputText: 'custom@example.com'

will be something like this

- tapOn:
    id: email-feild

- copyText: 'custom@example.com'
- pasteText 

Or even simplier - it could be just string argument to pasteText, so test will be

- tapOn:
    id: email-feild
- pasteText  'custom@example.com'

Anything else?

No response

bartekpacia commented 2 months ago

Hey @moxorama, thanks for proposing this.

I guess that by problems with "input flakiness" you mean issue #2005 – good news is there's already a PR #2027 that fixes issue #2005.

Anyway, I see why you might think that pasting text would be faster than typing – but actually, under the hood pasteText just calls inputText:

https://github.com/mobile-dev-inc/maestro/blob/af37642b32d1b2a0ee8c3558c9568c6b2677ec49/maestro-orchestra/src/main/java/maestro/orchestra/Orchestra.kt#L1171-L1174

So there'd be no difference in speed (unless we also made changes to how inputText works, which I think is doable, but requires some investigation if it would be stable enough on both iOS and Android).

That said, I think being able to set contents of clipboard with the hypothetical new copyText command would be a nice, small QoL addition.

copyText:
  text: This string will be saved in Maestro's clipboard

or

copyText: This string will be saved in Maestro's clipboard