Skip to content

Instantly share code, notes, and snippets.

@bootstraponline
Created January 31, 2015 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bootstraponline/3d9ccf603b8c01f877bf to your computer and use it in GitHub Desktop.
Save bootstraponline/3d9ccf603b8c01f877bf to your computer and use it in GitHub Desktop.
// id from R constant
String editTextUserInput = getTargetContext().getResources().getResourceName(R.id.editTextUserInput);
DroidDrivers.get().find(By.resourceId(editTextUserInput));
// hard coded id (same as above)
DroidDrivers.get().find(By.resourceId("com.example.android.testing.espresso.BasicSample:id/editTextUserInput"));
@bootstraponline
Copy link
Author

Both crash with:

:app:connectedAndroidTest

com.example.android.testing.espresso.BasicSample.ChangeTextBehaviorTest > testChangeText_sameActivity[Nexus 7 - 5.0.1] FAILED 
    com.google.android.droiddriver.exceptions.DroidDriverException: com.google.android.droiddriver.exceptions.DroidDriverException: Reflective access to private final java.util.ArrayList android.view.WindowManagerGlobal.mViews on android.view.WindowManagerGlobal@18294c04 failed.
    at com.google.android.droiddriver.instrumentation.InstrumentationDriver.findRootView(InstrumentationDriver.java:92)
:app:connectedAndroidTest FAILED

@0x1mason
Copy link

Did you call DroidDrivers#init before calling get?

@bootstraponline
Copy link
Author

@0x1mason yep, the full example is here. DroidDriver throws an exception if init isn't called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment