I have my uiautomator test case:
public class clickTest extends UiAutomatorTestCase {
public void myTest() throws UiObjectNotFoundException {
...
//Is it possible to get Context or Activity here?
}
}
I am wondering, is it possible to get Context
or Activity
instance in UiAutomatorTestCase
?
Or How to get PackageManager
in UiAutomatorTestCase
?
In 2021 this is the answer:
To get a Context for the target application being instrumented. See details here:
InstrumentationRegistry.getInstrumentation().getTargetContext();
To get the Context of the instrumentation's package. See details here:
InstrumentationRegistry.getInstrumentation().getContext();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With