Skip to content

Commit

Permalink
feat: Add mobile methods for lock and isLocked (#600)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Apr 20, 2023
1 parent 411fe39 commit 24e90b2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,16 @@ Name | Type | Required | Description | Example
apks | Array<string> | yes | The path to APKs. Each path should be the full path to the apk to be installed, or an URL to a remote location. | `['/path/to/local.apk', 'https://github.com/appium/ruby_lib_core/blob/master/test/functional/app/api.apk.zip?raw=true']`
options | object | no | Installation options. If you want enable `-g` option, you could specify that `{grantPermissions: true}`. `allowTestPackages` corresponds `-t`, `useSdcard` corresponds `-s`, `replace` corresponds `-r` (`-r` is enabled by default), `partialInstall` corresponds `-p`. | `{grantPermissions: true, partialInstall: true}`

### mobile: lock

Lock the device (and optionally unlock it after a certain amount of time). Only simple (e.g. without a password) locks are supported.

#### Arguments

Name | Type | Required | Description | Example
--- | --- | --- | --- | ---
seconds | number|string | no | The number of seconds after which to unlock the device. Set to `0` or leave it empty to require manual unlock (e.g. do not block and automatically unlock afterwards). | 5

### mobile: unlock

Unlocks the device if it is locked. Noop if the device's screen is not locked.
Expand All @@ -935,6 +945,14 @@ type | string | yes | The unlock type. See the documentation on [appium:unlockTy
strategy | string | no | Unlock strategy. See the documentation on [appium:unlockStrategy](#device-locking) capability for more details | uiautomator
timeoutMs | number | no | Unlock timeout. See the documentation on [appium:unlockSuccessTimeout](#device-locking) capability for more details | 5000

### mobile: isLocked

Determine whether the device is locked.

#### Returned Result

Either `true` or `false`

### mobile: refreshGpsCache

Sends a request to refresh the GPS cache on the device under test.
Expand Down
2 changes: 2 additions & 0 deletions lib/commands/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ extensions.executeMobile = async function (mobileCommand, opts = {}) {

installMultipleApks: 'mobileInstallMultipleApks',

lock: 'lock',
unlock: 'mobileUnlock',
isLocked: 'isLocked',

refreshGpsCache: 'mobileRefreshGpsCache',

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"dependencies": {
"@babel/runtime": "^7.0.0",
"appium-adb": "^9.11.0",
"appium-android-driver": "^5.10.0",
"appium-android-driver": "^5.10.4",
"appium-chromedriver": "^5.3.1",
"appium-uiautomator2-server": "^5.7.2",
"asyncbox": "^2.3.1",
Expand Down

0 comments on commit 24e90b2

Please sign in to comment.