|
| 1 | +# Unlock |
| 2 | + |
| 3 | +Espresso driver allows dealing with the Android lock screen using various APIs. |
| 4 | +This article describes the available APIs and their options. |
| 5 | + |
| 6 | +## Unlock On Session Startup |
| 7 | + |
| 8 | +Espresso driver provides the following [capabilities](../../README.md#device-locking) to deal |
| 9 | +with the system lock screen: |
| 10 | + |
| 11 | +- appium:unlockSuccessTimeout |
| 12 | +- appium:skipUnlock |
| 13 | +- appium:unlockType |
| 14 | +- appium:unlockKey |
| 15 | + |
| 16 | +These capabilities could be used to unlock the device under test during the driver session initialization |
| 17 | +as well as deal with different lock screen types. |
| 18 | + |
| 19 | +### appium:unlockSuccessTimeout |
| 20 | + |
| 21 | +Maximum number of milliseconds to wait until the device is unlocked. `2000` ms by default |
| 22 | + |
| 23 | +### appium:skipUnlock |
| 24 | + |
| 25 | +The `appium:skipUnlock` capability is enabled by default and makes the driver to detect and handle the lock screen |
| 26 | +upon session startup _if it is present_. If the lock screen cannot be detected upon session startup then nothing will be |
| 27 | +done. By default, it is assumed the device has a "simple" lock screen, which could be removed by waking up the device. |
| 28 | +In case the device has a different type of the lock screen configured in its settings then the information about it |
| 29 | +must be provided in the below capability values. |
| 30 | + |
| 31 | +### appium:unlockType and appium:unlockKey |
| 32 | + |
| 33 | +This capability supports the following possible values: |
| 34 | + |
| 35 | +#### pin |
| 36 | + |
| 37 | +Assumes the device is protected with a PIN code. Expects the `appium:unlockKey` to contain a valid pin consisting |
| 38 | +of digits in range 0-9, for example `1111`. |
| 39 | + |
| 40 | +#### password |
| 41 | + |
| 42 | +Assumes the device is protected with a password. Expects the `appium:unlockKey` to contain a valid password consisting |
| 43 | +of latin characters, for example `abcd1234`. |
| 44 | + |
| 45 | +#### pattern |
| 46 | + |
| 47 | +Assumes the device is protected with a secret pattern. Check the example below for more details on the `appium:unlockKey` |
| 48 | +value for this particular unlock type. |
| 49 | + |
| 50 | +##### Example |
| 51 | + |
| 52 | +Let say you have a device that is locked with a pattern similar to the one on the image below, |
| 53 | +and you want to run a test over that device. |
| 54 | + |
| 55 | +<img src="./screen1.png" /> |
| 56 | + |
| 57 | +We treat the pattern pins similarly to numbers on a digital phone dial. So, in this case the *unlockKey* is `729854163` |
| 58 | + |
| 59 | +<img src="./screen2.png" /> |
| 60 | + |
| 61 | +and capabilities are: |
| 62 | + |
| 63 | +```json |
| 64 | +{ |
| 65 | + "appium:unlockType": "pattern", |
| 66 | + "appium:unlockKey": "729854163" |
| 67 | +} |
| 68 | +``` |
| 69 | + |
| 70 | +## Mid-Session Unlock |
| 71 | + |
| 72 | +There is also a possibility to interact with the device's lock screen while the test session is running. |
| 73 | +Use the following mobile extensions for this purpose: |
| 74 | + |
| 75 | +- [mobile: lock](../../README.md#mobile-lock) |
| 76 | +- [mobile: unlock](../../README.md#mobile-unlock) |
| 77 | +- [mobile: isLocked](../../README.md#mobile-islocked) |
0 commit comments