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

Support for pressing Delete key on Android #1039

Closed
michaelgmcd opened this issue Nov 12, 2018 · 5 comments
Closed

Support for pressing Delete key on Android #1039

michaelgmcd opened this issue Nov 12, 2018 · 5 comments

Comments

@michaelgmcd
Copy link
Contributor

Unlike iOS, there doesn't appear a way to press the "Delete" key on Android. For iOS, I'm am able to use the typeText method and the "\b" string. From what I can tell through looking at the code is that either the UIDevice's pressDelete method or the Android Espresso pressKey method are the ways to solve this, however neither of these seem to be exposed to the JavaScript API.

@michaelgmcd
Copy link
Contributor Author

@LeoNatan, I can probably take care of the PR for this, we'll just need some discussion on the implementation. The way I see it, we can either:

  • Manually handle the \b key in the typeText element method on Android:
element.typeText('aa\bcc')
// on Android becomes 
element.typeText('aa')
element._pressKey(67) // internal
element.typeText('cc')
  • Expose the pressKey command on Android
    • It doesn't seem like EarlGrey has a pressKey command, so this would be Android only
    • Issue with this is that users will have to manually implement what's in the first option for a cross-platform test
  • Expose the pressDelete command on Android
    • Will also require users to manually implement the first option for cross-platform support
    • Doesn't support keys other than Delete

@LeoNatan
Copy link
Contributor

Sadly, \n and \b are not obvious at all on iOS. I think it's probably a good idea to have functions such as pressReturnKey() and pressBackspaceKey() on element (next to typeText), and then inside split the impl to typing \n on iOS and doing the necessary key press for Android. What do you think?

@LeoNatan
Copy link
Contributor

The pressKey() should remain internal, I think.

@LeoNatan
Copy link
Contributor

If you could submit a PR, that would be lovely. Thank you!

@michaelgmcd
Copy link
Contributor Author

I think the abstraction sounds nice. I'll take another look at this tonight. Should be able to open a PR.

@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

No branches or pull requests

3 participants