简体   繁体   中英

Unlocking the device by Ui automator 2.0

I'm am creating a ui-automator test for which I have to unlock my device and perform some task. I have removed all kind of locks in my phone (only unlock key and home key will unlock my device by simple click ) but when I'm using the following command it clicks the home button but rest of the things does not work. Is there any solution to unlock device using ui-automator?

Note : They work if the device is already unlocked

 mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
    mDevice.pressHome(); // only screen ligths are on

    UiObject CallB = mDevice.findObject(new UiSelector().description("Phone")); // test fails here :(
    CallB.clickAndWaitForNewWindow();

Try this function:

Device resume:

mDevice.wakeUp();   

Device suspend:

mDevice.sleep();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM