I’ve found a bug in our system when putting the device in sleep mode then waking it will cause the application to crash.
I want to start building automated test case around this. Has anyone attempted or achieved this.
Thanks for any help you can provide.
DD
what you mean sleep? iOS/Android?
Both Android and iOS. When you click one of the side button and the screen goes black.
I image I have to communicate with those buttons. ![:slight_smile: :slight_smile:](//discuss.appium.io/images/emoji/twitter/slight_smile.png?v=6)
Android:
((AndroidDriver) driver).lockDevice();
((AndroidDriver) driver).unlockDevice();
or
((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.KEYCODE_POWER);
((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.MENU);
For iOS - Simulator or Real?
Awesome, I’ll try it out.
Thanks Aleksei
For IOS I use both simulator and real depending on availability.
for real device - no idea. i do not use.
for Simulator i use osascript:
public void lockUnlockScreen() {
System.out.println(" lockUnlockScreen()");
//((IOSDriver) driver).lockDevice(2); // not implemented
tapLockButton();
sleep(1);
tapHomeButton();
sleep(1);
tapHomeButton();
}
public void tapHomeButton() {
System.out.println(" tapHomeButton()");
try {
String[] cmd = {"osascript", "-e", "tell application \""+simulatorAppName()+"\"\n" +
" activate\n" +
"end tell\n" +
" \n" +
"tell application \"System Events\"\n" +
" tell process \""+simulatorAppName()+"\"\n" +
" tell menu bar 1\n" +
" tell menu bar item \"Hardware\"\n" +
" tell menu \"Hardware\"\n" +
" click menu item \"Home\"\n" +
" end tell\n" +
" end tell\n" +
" end tell\n" +
" end tell\n" +
"end tell"};
executeShell(cmd);
try{Thread.sleep(500);}catch (Exception e1){}
} catch (Exception e) {}
}
public void tapLockButton() {
System.out.println(" tapLockButton()");
try {
String[] cmd = {"osascript", "-e", "tell application \""+simulatorAppName()+"\"\n" +
" activate\n" +
"end tell\n" +
" \n" +
"tell application \"System Events\"\n" +
" tell process \""+simulatorAppName()+"\"\n" +
" tell menu bar 1\n" +
" tell menu bar item \"Hardware\"\n" +
" tell menu \"Hardware\"\n" +
" click menu item \"Lock\"\n" +
" end tell\n" +
" end tell\n" +
" end tell\n" +
" end tell\n" +
"end tell"};
executeShell(cmd);
try{Thread.sleep(500);}catch (Exception e1){}
} catch (Exception e) {}
}
1 Like