I am trying to write an automated test to an android application that appears when you unlock your screen using the espresso framework. I would like to add a test case to ensure that an activity appears when the screen is unlocked.
How can I programmatically lock or unlock the screen using espresso?
I found that UiDevice has the desired methods. My final code:
UiDevice uiDevice = UiDevice.getInstance(getInstrumentation());
try {
uiDevice.sleep();
Thread.sleep(1000);
uiDevice.wakeUp();
Thread.sleep(1000);
} catch (RemoteException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
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