Unlock app in android is launching a blank screen only, resulting into Test Script failure

Hi All,

During the test execution, application is not getting launched on the device. It just shows unblock black screen and post that apk is not launching by the appium test scripts. If I unlock my phone manually then appium test scripts are running fine.

Any code block or suggestions are highly appreciated, please update my knowledge on how to unlock my phone first before running a test script.

Also if my device is locked then would appium driver be running fine ?

Please share your views.

Thanks,
Manish Sharma

Hi Manish, Even if device is locked, Appium does unlock operation automatically before launching an App in device.

Hey @Abdul_Sathar_Beigh,

Thanks for getting back !

I understand your point, script does launch unlock operation but then it fails to launch the app & I can only see the black screen of unlock operation. Later, when I manually unlock the phone and run the script it runs fine without any failure.

Not sure, what is wrong with my test scripts. Have you ever experienced the same ?

Really appreciate that you took time to reply to my query, Thanks again !

Regards,
Manish Sharma

Well Manish, I’ve not come across with such situation till now, and I really don’t understand why are you facing such problem. It will be helpful if you can post Appium log along with the code, so that I can offer you a better help. :smile:

Hi @Abdul_Sathar_Beigh,

I appreciate your response. Would like to inform that I ran my script again & it seems after the unlock black screen it launches the .apk, I checked it after unlocking my phone and the application was my current focus. I read through appium logs and below is that error

info: [debug] [BOOTSTRAP] [debug] Emitting system alert message
info: [debug] Emitting alert message…
info: → POST /wd/hub/session/a5f78020-e39d-461a-8eef-5530ed79b745/element {“using”:“id”,“value”:“com.ebay.mobile:id/button_sign_in”}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:“id”,“selector”:“com.ebay.mobile:id/button_sign_in”,“context”:“”,“multiple”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.ebay.mobile:id/button_sign_in”,“context”:“”,“multiple”:false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding com.ebay.mobile:id/button_sign_in using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.ebay.mobile:id/button_sign_in]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding com.ebay.mobile:id/button_sign_in using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.ebay.mobile:id/button_sign_in]
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:7,“value”:“No element found”}
info: [debug] Condition unmet after 1009ms. Timing out.
info: [debug] Responding to client with error: {“status”:7,“value”:{“message”:“An element could not be located on the page using the given search parameters.”,“origValue”:“No element found”},“sessionId”:“a5f78020-e39d-461a-8eef-5530ed79b745”}
info: ← POST /wd/hub/session/a5f78020-e39d-461a-8eef-5530ed79b745/element 500 1014.754 ms - 195
info: [debug] Didn’t get a new command in 60 secs, shutting down…
info: Shutting down appium session

Below is my code that would run after the app launch, now surprisingly this code runs fine if I manually unlock my phone first and then run the script. Please let me know if I need to focus first through any code block so that findelement and click function will run without any error.

WebElement signInButton = driver.findElementById("com.ebay.mobile:id/button_sign_in");
signInButton.click();

Please let me know if I am missing any step.

Thanks,
Manish Sharma

@Abdul_Sathar_Beigh

One more thing that I observed, my tests were continuously failing due to this error then using swipe pattern I unlocked my device I observed that .apk was in running mode from the back button I navigated back one step and saw unlock application (black screen with title unlock) I again press back button and now I am on the home page of my phone.

Now, if I lock my phone and unlock it from the power button I am seeing that my phone is not locked and it is not asking for any pattern rather it shows home screen. And from here if I run my test scripts it will always pass with 100% success.

My findings -
1- When I am running my scripts it tries to launch unlock application first but may be due to security level as pattern it is not executing webdriver commands, even though it launches the application on phone but it fails to recognize whether that app is open or not. Due to which I am always getting noelementfound exception

2- If I manually unlock it with a pattern somehow unlock application gets active from here and now it is not allowing any security pattern to get enabled again. That’s the reason scripts are running fine in this case.

I am definitely missing one step here. Would appreciate if you can help me through this. Let me know if any additional information is required.

Thanks,
Manish Sharma

I am facing the same issue here. Black screen and not unlocking

Fixed in appium 1.5.3

I am facing this same issue, is this resolved ?

Thanks

@vova-lohika it still doesn’t work for me as well , appium 1.5.3

I am also facing the same problem…

Are you guys seeing a black screen with an unlock button at the top? If that’s the case then its probably due to the passcode or pin that has been setup on the device. Try removing the passcode to that the device can be unlocked by just a swipe. Then try to run the Appium scripts and see if it works.

Remove any patterns, PINs, you should be able to run your tests smoothly.

The same issue is for me too.
I have to use security enabled(Pattern or Pin or Password) coz my app needs SSL certificate. If anyone has any kind of workaround then please let me know.

Note: This is happening for me on Android - Phone only. Working fine in Android - Tablet and iOS platform.

Thanks.

I have tried this but it did not unlock my android phone:

@Test
public void Tc3_Unlock_Pattern() throws Exception {
System.out.print(“TC3:Unlock pattern”);
Runtime.getRuntime().exec(“adb shell input swipe 257 1235 572 1235”);
Thread.sleep(500);
Runtime.getRuntime().exec(“adb shell input swipe 572 1235 260 1564”);
Thread.sleep(500);
Runtime.getRuntime().exec(“adb shell input swipe 260 1564 532 1504”);
Thread.sleep(500);
System.out.print(“TC3:Executed Successfully”);
}

.I even tried this but it did not work:

Integer x_topLeftCorner=257;
Integer y_topLeftCorner=1235;

Integer x_topRightCorner=572;
Integer y_topRightCorner=1235;

Integer x_bottomLeftCorner= 260;
Integer y_bottomLeftCorner=1438;

Integer x_bottomRightCorner=532;
Integer y_bottomRightCorner=1504;

//Use coordinates to draw the security pattern and unlock the screen 
TouchAction obj = new TouchAction(MBase.getDriver()); 
obj.press(x_topLeftCorner,y_topLeftCorner).moveTo(x_topRightCorner,y_topRightCorner).moveTo(x_bottomLeftCor

i am having almost the same problem with you guyz, the difference is it open the app but the not complete, it only shows two function at the bottom and it opens the app like its new, like it’s the first time i am using it.
this happens all the time i run it. it’s happening on appium 1.6.5