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: