Cannot unlock screen in iOS device (Simulator)

Hi ,

I’m trying to lock / unlock iOS simulator’s device

driver.lockScreen(10);

Does the job , but the thing is , after the timeout (10s) the device hasn’t been unlocked

It stays i locked state

The appium log :

info: --> POST /wd/hub/session/0d80a422-aadb-47db-a1cd-2a269226756e/appium/device/lock {"seconds":10}

info: [debug] Pushing command to appium work queue: "au.lock(10)"

info: [debug] Sending command to instruments: au.lock(10)

info: [debug] [INST] 2015-08-06 14:50:16 +0000 Debug: Got new command 9 from instruments: au.lock(10)

info: [debug] [INST] 2015-08-06 14:50:16 +0000 Debug: evaluating au.lock(10)

info: [debug] [INST] 2015-08-06 14:50:16 +0000 Debug: target.lockForDuration("10")

info: [debug] [INST] 2015-08-06 14:50:27 +0000 Debug: target.springboard().mainWindow().scrollViews().firstWithPredicate("ANY elements.name == 'SlideToUnlock' OR ANY elements.name == 'SlideToSetup'").dragInsideWithOptions({endOffset:{x:0.90,y:0.90}}, duration:"0.5", startOffset:{x:0.10,y:0.90}}})

info: [debug] [INST] 2015-08-06 14:50:29 +0000 Debug: evaluation finished

info: [debug] [INST] 2015-08-06 14:50:29 +0000 Debug: responding with:

info: [debug] [INST] 2015-08-06 14:50:29 +0000 Debug: Running system command #10: /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":false}...

I’ve also tried to swipe with :
driver.swipe
touchAction

nothing works for me

Any idea how to unlock the screen ? or what I’m doing wrong ?

Thanks

Appium guys , any input ?

I haven’t used the lock method, so can’t help you with that, but with swiping, you need to change context to NATIVE_APP. Can you try that?

@DavidSelby - the context is a native already …

The “SlideToUnlock” is a native iOS control…

I haven’t used the lock method, so can’t help you with that, but with swiping, you need to change context to NATIVE_APP. Can you try that?

That worked for me, thanks.

Edit: I take that back… I mistook my attempts at swiping with the sporadic success of Appium’s built-in attempts to unlock the device. I’ve never actually gotten it to succeed with my own swiping attempts, even after trying many different values for the swipes.

It seems really strange that Appium’s attempts to unlock the device sometimes succeed and sometimes fail without any changes from my end:

failure:

info: [debug] [INST] 2015-10-30 23:03:18 +0000 Debug: target.systemApp().mainWindow().scrollViews().firstWithPredicate("ANY elements.name == 'SlideToUnlock' OR ANY elements.name == 'SlideToSetup' OR ANY elements.name == 'Passcode field'").dragInsideWithOptions({endOffset:{x:0.90,y:0.90}}, duration:"0.5", startOffset:{x:0.20,y:0.90}}})

info: [debug] [INST] 2015-10-30 23:03:19 +0000 Debug: Unlock failed. Retrying up to 2 more time(s).

info: [debug] [INST] 2015-10-30 23:03:19 +0000 Debug: target.systemApp().mainWindow().scrollViews().firstWithPredicate("ANY elements.name == 'SlideToUnlock' OR ANY elements.name == 'SlideToSetup' OR ANY elements.name == 'Passcode field'").dragInsideWithOptions({endOffset:{x:0.90,y:0.90}}, duration:"0.5", startOffset:{x:0.20,y:0.90}}})

info: [debug] [INST] 2015-10-30 23:03:21 +0000 Debug: Unlock failed. Retrying up to 1 more time(s).

info: [debug] [INST] 2015-10-30 23:03:21 +0000 Debug: target.systemApp().mainWindow().scrollViews().firstWithPredicate("ANY elements.name == 'SlideToUnlock' OR ANY elements.name == 'SlideToSetup' OR ANY elements.name == 'Passcode field'").dragInsideWithOptions({endOffset:{x:0.90,y:0.90}}, duration:"0.5", startOffset:{x:0.20,y:0.90}}})

info: [debug] [INST] 2015-10-30 23:03:23 +0000 Debug: evaluation finished

success:

info: [debug] [INST] 2015-10-30 22:58:31 +0000 Debug: target.systemApp().mainWindow().scrollViews().firstWithPredicate("ANY elements.name == 'SlideToUnlock' OR ANY elements.name == 'SlideToSetup' OR ANY elements.name == 'Passcode field'").dragInsideWithOptions({endOffset:{x:0.90,y:0.90}}, duration:"0.5", startOffset:{x:0.20,y:0.90}}})



info: [debug] [INST] 2015-10-30 22:58:33 +0000 Debug: Unlock failed. Retrying up to 2 more time(s).


    
    info: [debug] [INST] 2015-10-30 22:58:33 +0000 Debug: 

    target.systemApp().mainWindow().scrollViews().firstWithPredicate("ANY elements.name == 'SlideToUnlock' OR ANY elements.name == 'SlideToSetup' OR ANY elements.name == 'Passcode field'").dragInsideWithOptions({endOffset:{x:0.90,y:0.90}}, duration:"0.5", startOffset:{x:0.20,y:0.90}}})
    
(unlocking succeeds here)

I’m testing an iOS simulator (8.4) of the iPad 2 with xcode 6.4 using the latest version of Appium (1.4.13).

One thing that’s curious is that Appium acts like the App’s elements are still visible while the device is locked, which would seem to make locking/unlocking the device sort of meaningless: