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

Android feedback #334

Closed
SMJ93 opened this issue Oct 11, 2017 · 15 comments
Closed

Android feedback #334

SMJ93 opened this issue Oct 11, 2017 · 15 comments

Comments

@SMJ93
Copy link
Contributor

SMJ93 commented Oct 11, 2017

Great work with Android guys!

I managed to get it working using this example as a starting point, but experienced a few issues along the way. Here are the issues I encountered and how I solved them in case anyone has them:

  1. On some simulators it tries to unlock the phone before loading the simulator (in this case Pixel_API_26):
    Error: Command failed: /Users/username/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell input keyevent 82 (exited with error code 137)

To get around this I changed to the Nexus_5_API_26 simulator in the package.json.

A long term solution so this works on all simulators could be adding a wait for simulator to finish loading before triggering this event?

  1. Jackson core version conflict. Detox uses jackson.core version 2.2.3, but our project uses 2.8.7 which caused a dependency conflict - read more about it here.

To fix this we added the following to the app/build.gradle:

androidTestCompile 'com.fasterxml.jackson.core:jackson-core:2.8.7

  1. Google play services popup

We are using Google play services inside our app which displayed a popup when first loading up the simulator asking us to update. This blocked the interaction with the app resulting in all tests timing out.

To fix this problem we manually updated the simulator to the latest version of Google Play Services.

But overall our experience with Android has been fantastic! We are still experiencing issues with iOS and React Native Firebase (#270) so have moved our attention over to Android for the time being.

Some ideas for the future:

  • Support iframe interactions
  • Support for date pickers, select inputs and other form elements
  • Support jest as an alternative to mocha inside detox-cli

Environment

  • Detox: 5.8.1
  • Node: 8.1.0
  • Device: Android Simulators
  • macOS: 10.12.6

Thanks again guys and keep up the good work!

@rotemmiz
Copy link
Member

Thanks for the feedback!!

Regarding your points:

  1. Do you mean that the shell input keyevent 82 doesn't work on older devices? or is it a synchronization issues ?
  2. I think it was a wrong decision to use Jackson in a library project, but it was the fastest way to go. I think we need to replace it with a custom parser using JSONObject, I also think it's gonna be pretty easy and safe since this area is 100% unit tested. so if anyway is up for the task (hint hint!!).
  3. You can use UIAutomator to press any out of process alert. We need to define the API better, but we already use it internally (switching back to app from recent apps, etc`).

@SMJ93
Copy link
Contributor Author

SMJ93 commented Oct 11, 2017

@rotemmiz thanks for the quick response!

  1. The shell input works on all the devices I tested when the simulator had finished booting up. It seems to be a simulator loading issue with some devices where it tries to call the shell input keyevent 82 when the simulator is offline.

  2. Makes sense. I will try and find some time to look into replacing it 👍

  3. Cool, I will give it a go!

Regarding the other features, are these on the road map?

  • Support iframe interactions
  • Support for date pickers, select inputs and other form elements
  • Support jest as an alternative to mocha inside detox-cli

@rotemmiz
Copy link
Member

  • Not sure what iframe interactions mean, can you elaborate ?
  • We can support it, but this task may take some time, and we are focused on supporting modern RN versions, and stabilizing Android...
  • Basic support for Jest runner #335

@SMJ93
Copy link
Contributor Author

SMJ93 commented Oct 11, 2017

  • We use an iframe mid way our flow for 3rd party services using react-native WebView. We need to interact with these using button taps and typing in text inputs.
  • Yeah that makes sense, I'll have a play with them and PR some docs if I manage to get something working.
  • Perfect timing haha, cheers @rotemmiz

@rotemmiz
Copy link
Member

There is no support inside webviews, but you can set a testID to that webview and use tapAtPoint(x,y)

@SMJ93
Copy link
Contributor Author

SMJ93 commented Oct 12, 2017

@rotemmiz thanks! That allows us to focus on the text input which opens up the keyboard. Is there anyway to tap keyboard keys?

Also I am having problems interacting with native ScrollViews with no testID's (tags). I have tried await element(by.type('ScrollView')); and other of the ActionsOnElements, but none seem to find it which results in an expresso error.

This is how it appears in the Android view hierarchy:

ScrollView{id=-1, visibility=VISIBLE, width=864, height=1014, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@8fdfa24, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=279.0, child-count=1}

@rotemmiz
Copy link
Member

Use the full java class name when you use by.type: by.type('android.widget.ScrollView')

@SMJ93
Copy link
Contributor Author

SMJ93 commented Oct 12, 2017

@rotemmiz yup that works! Now I am getting a matcher error because there are 2 ScrollViews.

There seems to be a typo in the atIndex() method.

await element(by.type('android.widget.ScrollView')).atIndex(0).scroll(100, 'up');

Error:

Error: Error: No such accessible method: matherForAtIndex() on class: com.wix.detox.espresso.DetoxMatcher

@rotemmiz
Copy link
Member

Was already fixed on master. out in next release.

@SMJ93
Copy link
Contributor Author

SMJ93 commented Oct 12, 2017

@rotemmiz Awesome! I've fixed the typo locally, but get the following error when running:

await element(by.type('android.widget.ScrollView')).atIndex(1).scroll(100, 'up');

Error: Error: Error performing 'scrollInDirection' on view 'matches 1th view.'.

I'm guessing you cant call .atIndex() followed by .scroll()?

Same happens with click and swipe too.

@rotemmiz
Copy link
Member

It looks like we don't have e2e tests for atIndex, and this is a real issue. Please open a different issue about that.

Thanks!

@SMJ93
Copy link
Contributor Author

SMJ93 commented Oct 12, 2017

Cool, i've logged #337. Let me know if you need any other details.

Going back to the iFrame, is there a way to access the hardware keyboard?

@rotemmiz
Copy link
Member

rotemmiz commented Oct 12, 2017

Not that I am aware of, but we might need to take a look at UIAutomator/Espresso/EarlGray and add manual control over keyboard from device.

@SMJ93
Copy link
Contributor Author

SMJ93 commented Oct 12, 2017

Alright, cheers @rotemmiz. I'm moving house at the moment, but i'll try and find some time of the next few weeks to contribute!

@anniewey
Copy link

I'm facing similar issue (1) :

ChildProcessError: Command failed: /Users/username/Library/Android/sdk/platform-tools/adb -s 2be4c8be0004 shell input keyevent 82
 `/Users/username/Library/Android/sdk/platform-tools/adb -s 2be4c8be0004 shell input keyevent 82` (exited with error code 137)

I'm using android.attached instead of android.emulator. Is there any workaround for this for me to test using physical device?

@wix wix locked and limited conversation to collaborators Jul 23, 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

4 participants