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

New Actions: tapBackspaceKey and tapReturnKey #1044

Merged
merged 4 commits into from
Nov 16, 2018
Merged

Conversation

michaelgmcd
Copy link
Contributor

@michaelgmcd michaelgmcd commented Nov 14, 2018


This PR adds support for pressing the backspace and return keys on both iOS and Android. Although iOS support exists by using typeText and the \b and \n keys, this was unclear and not cross-platform. The pressBackspaceKey and pressReturnKey methods abstract these features for both platforms.

Note: I did try adding a numberOfTimes parameter as a shortcut for pressing the backspace or return key multiple times, however I wasn't able to figure out the simplest way for executing multiple actions:

For both Android and iOS, the addition numberOfTimes for pressReturnKey is pretty straightforward:

async pressReturnKey(numberOfTimes = 1) {
  if (numberOfTimes && typeof numberOfTimes !== 'number') { throw new Error('...') }
  return await new ActionInteraction(this, new TypeTextAction('\n'.repeat(numberOfTimes))).execute();
}

For pressBackspaceKey on iOS, it can be implemented the same way as return, replacing \n with \b. For Android, however, I'm not sure how to invoke multiple PressKeyActions. Either way, I think this can be added in a follow up PR if it's determined to be useful.

cc @LeoNatan

@LeoNatan
Copy link
Contributor

Fantastic, thank you!
Would I trouble you much if I ask to name them tap...? It was my fault with the press in the issue, but on iOS that has different meanings. Tapping is the agreed upon terminology for iOS and Android.

@michaelgmcd
Copy link
Contributor Author

Done @LeoNatan.

@LeoNatan
Copy link
Contributor

Looks good to me. Let's wait for @rotemmiz review as well.

@michaelgmcd michaelgmcd changed the title feature: support pressBackspaceKey and pressReturnKey feature: support tapBackspaceKey and tapReturnKey Nov 14, 2018
@michaelgmcd
Copy link
Contributor Author

@rotemmiz Any idea when you'll be able to get to this? It's a blocker for my team moving to Detox (which we'd love to do asap)

@rotemmiz
Copy link
Contributor

Looks great! Let's just add a few lines of documentation in https://github.com/wix/Detox/blob/master/docs/APIRef.ActionsOnElement.md

@rotemmiz
Copy link
Contributor

Amaze!

@LeoNatan
Copy link
Contributor

👍

@michaelgmcd
Copy link
Contributor Author

@rotemmiz @LeoNatan Are we good to go?

@rotemmiz rotemmiz changed the title feature: support tapBackspaceKey and tapReturnKey New Actions: tapBackspaceKey and tapReturnKey Nov 16, 2018
@rotemmiz rotemmiz merged commit bc0d6db into wix:master Nov 16, 2018
@rotemmiz
Copy link
Contributor

Thank you!

@michaelgmcd
Copy link
Contributor Author

Any timeframe on when this will be released?

@rotemmiz
Copy link
Contributor

rotemmiz commented Nov 16, 2018

After a few inconsistencies with lerna 3, and some faulty release, you can now find your changes in
detox@9.1.2

@lock lock bot locked as resolved and limited conversation to collaborators Nov 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants