unlock
Unlock the device screen.
Note: Falls back to the deprecated Appium 2 protocol endpoint if the driver does not support the
mobile:execute method.
Usage
browser.unlock({ strategy, timeoutMs, unlockKey, unlockType })
Parameters
| Name | Type | Details |
|---|---|---|
optionsoptional | object | Unlock options (Android only) |
options.strategyoptional | string | The unlock strategy to use. Accepted values: 'locksettings' (default) or 'uiautomator'. ANDROID-ONLY |
options.timeoutMsoptional | number | The timeout in milliseconds to wait for the unlock to complete. Default is 2000. ANDROID-ONLY |
options.unlockKeyoptional | string | The PIN, password, or pattern to use for unlocking. Required when the device has a PIN/password lock. ANDROID-ONLY |
options.unlockTypeoptional | string | The type of lock mechanism on the device (e.g. 'pin', 'password', 'pattern'). ANDROID-ONLY |
Example
unlock.js
it('should unlock the device screen', async () => {
// Unlock with no arguments (iOS or Android with default settings)
await browser.unlock()
})
it('should unlock Android with a PIN', async () => {
// Android-only: unlock using locksettings strategy with a PIN
await browser.unlock({
strategy: 'locksettings',
unlockType: 'pin',
unlockKey: '1234'
})
})
it('should unlock Android with a custom timeout', async () => {
// Android-only: unlock with a custom timeout
await browser.unlock({ timeoutMs: 5000 })
})
Support
குறிப்பு
Refer to the official Appium driver documentation to see which driver versions support this command.