MCPcopy
hub / github.com/appium/python-client / lock

Method lock

appium/webdriver/extensions/hw_actions.py:28–47  ·  view source on GitHub ↗

Lock the device. No changes are made if the device is already unlocked. Args: seconds: The duration to lock the device, in seconds. The device is going to be locked forever until `unlock` is called if it equals or is less than zero, otherwise this

(self, seconds: Optional[int] = None)

Source from the content-addressed store, hash-verified

26
27class HardwareActions(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresence):
28 def lock(self, seconds: Optional[int] = None) -> Self:
29 """Lock the device. No changes are made if the device is already unlocked.
30
31 Args:
32 seconds: The duration to lock the device, in seconds.
33 The device is going to be locked forever until `unlock` is called
34 if it equals or is less than zero, otherwise this call blocks until
35 the timeout expires and unlocks the screen automatically.
36
37 Returns:
38 Union['WebDriver', 'HardwareActions']: Self instance
39 """
40 ext_name = 'mobile: lock'
41 args = {'seconds': seconds or 0}
42 try:
43 self.assert_extension_exists(ext_name).execute_script(ext_name, args)
44 except UnknownMethodException:
45 # TODO: Remove the fallback
46 self.mark_extension_absence(ext_name).execute(Command.LOCK, args)
47 return self
48
49 def unlock(self) -> Self:
50 """Unlock the device. No changes are made if the device is already locked.

Callers 4

test_lockMethod · 0.80
test_lock_no_argsMethod · 0.80
test_lockMethod · 0.80
test_lock_no_argsMethod · 0.80

Calls 4

execute_scriptMethod · 0.80
executeMethod · 0.45

Tested by 4

test_lockMethod · 0.64
test_lock_no_argsMethod · 0.64
test_lockMethod · 0.64
test_lock_no_argsMethod · 0.64