0% found this document useful (0 votes)
19 views

appium_python_client_webdriver_extensions

Sphinx converted to PDF

Uploaded by

kevinkre
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

appium_python_client_webdriver_extensions

Sphinx converted to PDF

Uploaded by

kevinkre
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

webdriver.

extensions package

Subpackages
webdriver.extensions.android package

Submodules
webdriver.extensions.android.ac vi es module

Activities

Activities.current_activity

Activities.wait_activity()

webdriver.extensions.android.common module

Common

Common.current_package

Common.open_notifications()

webdriver.extensions.android.display module

Display

Display.get_display_density()

webdriver.extensions.android.gsm module

Gsm

Gsm.make_gsm_call()

Gsm.set_gsm_signal()

Gsm.set_gsm_voice()

GsmCallActions

GsmCallActions.ACCEPT

GsmCallActions.CALL

GsmCallActions.CANCEL

GsmCallActions.HOLD

GsmSignalStrength

GsmSignalStrength.GOOD

GsmSignalStrength.GREAT

GsmSignalStrength.MODERATE

GsmSignalStrength.NONE_OR_UNKNOWN

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
GsmSignalStrength.POOR

GsmVoiceState

GsmVoiceState.DENIED

GsmVoiceState.HOME

GsmVoiceState.OFF

GsmVoiceState.ON

GsmVoiceState.ROAMING

GsmVoiceState.SEARCHING

GsmVoiceState.UNREGISTERED

webdriver.extensions.android.na vekey module

AndroidKey

AndroidKey.A

AndroidKey.ALT_LEFT

AndroidKey.ALT_RIGHT

AndroidKey.APOSTROPHE

AndroidKey.APP_SWITCH

AndroidKey.ASSIST

AndroidKey.AT

AndroidKey.AVR_INPUT

AndroidKey.AVR_POWER

AndroidKey.B

AndroidKey.BACK

AndroidKey.BACKSLASH

AndroidKey.BOOKMARK

AndroidKey.BREAK

AndroidKey.BRIGHTNESS_DOWN

AndroidKey.BRIGHTNESS_UP

AndroidKey.BUTTON_1

AndroidKey.BUTTON_10

AndroidKey.BUTTON_11

AndroidKey.BUTTON_12

AndroidKey.BUTTON_13

AndroidKey.BUTTON_14

AndroidKey.BUTTON_15

AndroidKey.BUTTON_16

AndroidKey.BUTTON_2

AndroidKey.BUTTON_3

AndroidKey.BUTTON_4

AndroidKey.BUTTON_5

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
AndroidKey.BUTTON_6

AndroidKey.BUTTON_7

AndroidKey.BUTTON_8

AndroidKey.BUTTON_9

AndroidKey.BUTTON_A

AndroidKey.BUTTON_B

AndroidKey.BUTTON_C

AndroidKey.BUTTON_L1

AndroidKey.BUTTON_L2

AndroidKey.BUTTON_MODE

AndroidKey.BUTTON_R1

AndroidKey.BUTTON_R2

AndroidKey.BUTTON_SELECT

AndroidKey.BUTTON_START

AndroidKey.BUTTON_THUMBL

AndroidKey.BUTTON_THUMBR

AndroidKey.BUTTON_X

AndroidKey.BUTTON_Y

AndroidKey.BUTTON_Z

AndroidKey.C

AndroidKey.CALCULATOR

AndroidKey.CALENDAR

AndroidKey.CALL

AndroidKey.CAMERA

AndroidKey.CAPS_LOCK

AndroidKey.CAPTIONS

AndroidKey.CHANNEL_DOWN

AndroidKey.CHANNEL_UP

AndroidKey.CLEAR

AndroidKey.COMMA

AndroidKey.CONTACTS

AndroidKey.COPY

AndroidKey.CTRL_LEFT

AndroidKey.CTRL_RIGHT

AndroidKey.CUT

AndroidKey.D

AndroidKey.DEL

AndroidKey.DIGIT_0

AndroidKey.DIGIT_1

AndroidKey.DIGIT_2

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
AndroidKey.DIGIT_3

AndroidKey.DIGIT_4

AndroidKey.DIGIT_5

AndroidKey.DIGIT_6

AndroidKey.DIGIT_7

AndroidKey.DIGIT_8

AndroidKey.DIGIT_9

AndroidKey.DPAD_CENTER

AndroidKey.DPAD_DOWN

AndroidKey.DPAD_DOWN_LEFT

AndroidKey.DPAD_DOWN_RIGHT

AndroidKey.DPAD_LEFT

AndroidKey.DPAD_RIGHT

AndroidKey.DPAD_UP

AndroidKey.DPAD_UP_LEFT

AndroidKey.DPAD_UP_RIGHT

AndroidKey.DVR

AndroidKey.E

AndroidKey.EISU

AndroidKey.ENDCALL

AndroidKey.ENTER

AndroidKey.ENVELOPE

AndroidKey.EQUALS

AndroidKey.ESCAPE

AndroidKey.EXPLORER

AndroidKey.F

AndroidKey.F1

AndroidKey.F10

AndroidKey.F11

AndroidKey.F12

AndroidKey.F2

AndroidKey.F3

AndroidKey.F4

AndroidKey.F5

AndroidKey.F6

AndroidKey.F7

AndroidKey.F8

AndroidKey.F9

AndroidKey.FOCUS

AndroidKey.FORWARD

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
AndroidKey.FORWARD_DEL

AndroidKey.FUNCTION

AndroidKey.G

AndroidKey.GRAVE

AndroidKey.GUIDE

AndroidKey.H

AndroidKey.HEADSETHOOK

AndroidKey.HELP

AndroidKey.HENKAN

AndroidKey.HOME

AndroidKey.I

AndroidKey.INFO

AndroidKey.INSERT

AndroidKey.J

AndroidKey.K

AndroidKey.KANA

AndroidKey.KATAKANA_HIRAGANA

AndroidKey.KEYCODE_ZOOM_IN

AndroidKey.KEYCODE_ZOOM_OUT

AndroidKey.KEY_11

AndroidKey.KEY_12

AndroidKey.L

AndroidKey.LANGUAGE_SWITCH

AndroidKey.LAST_CHANNEL

AndroidKey.LEFT_BRACKET

AndroidKey.M

AndroidKey.MANNER_MODE

AndroidKey.MEDIA_AUDIO_TRACK

AndroidKey.MEDIA_CLOSE

AndroidKey.MEDIA_EJECT

AndroidKey.MEDIA_FAST_FORWARD

AndroidKey.MEDIA_NEXT

AndroidKey.MEDIA_PAUSE

AndroidKey.MEDIA_PLAY

AndroidKey.MEDIA_PLAY_PAUSE

AndroidKey.MEDIA_PREVIOUS

AndroidKey.MEDIA_RECORD

AndroidKey.MEDIA_REWIND

AndroidKey.MEDIA_SKIP_BACKWARD

AndroidKey.MEDIA_SKIP_FORWARD

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
AndroidKey.MEDIA_STEP_BACKWARD

AndroidKey.MEDIA_STEP_FORWARD

AndroidKey.MEDIA_STOP

AndroidKey.MEDIA_TOP_MENU

AndroidKey.MENU

AndroidKey.META_LEFT

AndroidKey.META_RIGHT

AndroidKey.MINUS

AndroidKey.MODE_3D

AndroidKey.MOVE_END

AndroidKey.MOVE_HOME

AndroidKey.MUHENKAN

AndroidKey.MUSIC

AndroidKey.MUTE

AndroidKey.N

AndroidKey.NAVIGATE_IN

AndroidKey.NAVIGATE_NEXT

AndroidKey.NAVIGATE_OUT

AndroidKey.NAVIGATE_PREVIOUS

AndroidKey.NOTIFICATION

AndroidKey.NUM

AndroidKey.NUMPAD_0

AndroidKey.NUMPAD_1

AndroidKey.NUMPAD_2

AndroidKey.NUMPAD_3

AndroidKey.NUMPAD_4

AndroidKey.NUMPAD_5

AndroidKey.NUMPAD_6

AndroidKey.NUMPAD_7

AndroidKey.NUMPAD_8

AndroidKey.NUMPAD_9

AndroidKey.NUMPAD_ADD

AndroidKey.NUMPAD_COMMA

AndroidKey.NUMPAD_DIVIDE

AndroidKey.NUMPAD_DOT

AndroidKey.NUMPAD_ENTER

AndroidKey.NUMPAD_EQUALS

AndroidKey.NUMPAD_LEFT_PAREN

AndroidKey.NUMPAD_MULTIPLY

AndroidKey.NUMPAD_RIGHT_PAREN

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
AndroidKey.NUMPAD_SUBTRACT

AndroidKey.NUM_LOCK

AndroidKey.O

AndroidKey.P

AndroidKey.PAGE_DOWN

AndroidKey.PAGE_UP

AndroidKey.PAIRING

AndroidKey.PERIOD

AndroidKey.PICTSYMBOLS

AndroidKey.PLUS

AndroidKey.POUND

AndroidKey.POWER

AndroidKey.PROG_BLUE

AndroidKey.PROG_GREEN

AndroidKey.PROG_RED

AndroidKey.PROG_YELLOW

AndroidKey.Q

AndroidKey.R

AndroidKey.RIGHT_BRACKET

AndroidKey.RO

AndroidKey.S

AndroidKey.SCROLL_LOCK

AndroidKey.SEARCH

AndroidKey.SEMICOLON

AndroidKey.SETTINGS

AndroidKey.SHIFT_LEFT

AndroidKey.SHIFT_RIGHT

AndroidKey.SLASH

AndroidKey.SLEEP

AndroidKey.SOFT_LEFT

AndroidKey.SOFT_RIGHT

AndroidKey.SOFT_SLEEP

AndroidKey.SPACE

AndroidKey.STAR

AndroidKey.STB_INPUT

AndroidKey.STB_POWER

AndroidKey.STEM_1

AndroidKey.STEM_2

AndroidKey.STEM_3

AndroidKey.STEM_PRIMARY

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
AndroidKey.SWITCH_CHARSET

AndroidKey.SYM

AndroidKey.SYSRQ

AndroidKey.T

AndroidKey.TAB

AndroidKey.TV

AndroidKey.TV_ANTENNA_CABLE

AndroidKey.TV_AUDIO_DESCRIPTION

AndroidKey.TV_AUDIO_DESCRIPTION_MIX_DOWN

AndroidKey.TV_AUDIO_DESCRIPTION_MIX_UP

AndroidKey.TV_CONTENTS_MENU

AndroidKey.TV_DATA_SERVICE

AndroidKey.TV_INPUT

AndroidKey.TV_INPUT_COMPONENT_1

AndroidKey.TV_INPUT_COMPONENT_2

AndroidKey.TV_INPUT_COMPOSITE_1

AndroidKey.TV_INPUT_COMPOSITE_2

AndroidKey.TV_INPUT_HDMI_1

AndroidKey.TV_INPUT_HDMI_2

AndroidKey.TV_INPUT_HDMI_3

AndroidKey.TV_INPUT_HDMI_4

AndroidKey.TV_INPUT_VGA_1

AndroidKey.TV_MEDIA_CONTEXT_MENU

AndroidKey.TV_NETWORK

AndroidKey.TV_NUMBER_ENTRY

AndroidKey.TV_POWER

AndroidKey.TV_RADIO_SERVICE

AndroidKey.TV_SATELLITE

AndroidKey.TV_SATELLITE_BS

AndroidKey.TV_SATELLITE_CS

AndroidKey.TV_SATELLITE_SERVICE

AndroidKey.TV_TELETEXT

AndroidKey.TV_TERRESTRIAL_ANALOG

AndroidKey.TV_TERRESTRIAL_DIGITAL

AndroidKey.TV_TIMER_PROGRAMMING

AndroidKey.TV_ZOOM_MODE

AndroidKey.U

AndroidKey.UNKNOWN

AndroidKey.V

AndroidKey.VOICE_ASSIST

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
AndroidKey.VOLUME_DOWN

AndroidKey.VOLUME_MUTE

AndroidKey.VOLUME_UP

AndroidKey.W

AndroidKey.WAKEUP

AndroidKey.WINDOW

AndroidKey.X

AndroidKey.Y

AndroidKey.YEN

AndroidKey.Z

AndroidKey.ZENKAKU_HANKAKU

AndroidKey.confirm_buttons

AndroidKey.gamepad_buttons

AndroidKey.is_confirm_key()

AndroidKey.is_gamepad_button()

AndroidKey.is_media_key()

AndroidKey.is_system_key()

AndroidKey.is_wake_key()

AndroidKey.media_buttons

AndroidKey.system_buttons

AndroidKey.wake_buttons

webdriver.extensions.android.network module

NetSpeed

NetSpeed.EDGE

NetSpeed.EVDO

NetSpeed.FULL

NetSpeed.GPRS

NetSpeed.GSM

NetSpeed.HSDPA

NetSpeed.LTE

NetSpeed.SCSD

NetSpeed.UMTS

Network

Network.network_connection

Network.set_network_connection()

Network.set_network_speed()

Network.toggle_wifi()

NetworkMask

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
NetworkMask.AIRPLANE_MODE

NetworkMask.DATA

NetworkMask.WIFI

webdriver.extensions.android.performance module

Performance

Performance.get_performance_data()

Performance.get_performance_data_types()

webdriver.extensions.android.power module

Power

Power.AC_OFF

Power.AC_ON

Power.set_power_ac()

Power.set_power_capacity()

webdriver.extensions.android.sms module

Sms

Sms.send_sms()

webdriver.extensions.android.system_bars module

SystemBars

SystemBars.get_system_bars()

Module contents
webdriver.extensions.flu er_integra on package

Submodules
webdriver.extensions.flu er_integra on.flu er_commands module

FlutterCommand

FlutterCommand.activate_injected_image()

FlutterCommand.execute_flutter_command()

FlutterCommand.inject_mock_image()

FlutterCommand.perform_double_click()

FlutterCommand.perform_drag_and_drop()

FlutterCommand.perform_long_press()

FlutterCommand.scroll_till_visible()

FlutterCommand.wait_for_invisible()

FlutterCommand.wait_for_visible()

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
webdriver.extensions.flu er_integra on.flu er_finder module

FlutterFinder

FlutterFinder.as_args()

FlutterFinder.by_key()

FlutterFinder.by_semantics_label()

FlutterFinder.by_text()

FlutterFinder.by_text_containing()

FlutterFinder.by_type()

FlutterFinder.to_dict()

webdriver.extensions.flu er_integra on.scroll_direc ons module

ScrollDirection

ScrollDirection.DOWN

ScrollDirection.UP

Module contents

Submodules

webdriver.extensions.action_helpers module

class ActionHelpers

Bases: object

drag_and_drop(origin_el: WebElement, des na on_el: WebElement, pause: float | None = None)→ Self

Drag the origin element to the des na on element

Parameters: origin_el – the element to drag


des na on_el – the element to drag to
pause – how long the ac on pauses before moving a er the tap and hold, in
float seconds.
Returns: Self instance
Return type: Union[‘WebDriver’, ‘Ac onHelpers’]

flick(start_x: int, start_y: int, end_x: int, end_y: int)→ Self

Flick from one point to another point.

Parameters: start_x – x-coordinate at which to start


start_y – y-coordinate at which to start
end_x – x-coordinate at which to stop
end_y – y-coordinate at which to stop

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Usage:

driver.flick(100, 100, 100, 400)

Returns: Self instance


Return type: Union[‘WebDriver’, ‘Ac onHelpers’]

scroll(origin_el: WebElement, des na on_el: WebElement, dura on: int | None = None)→ Self

Scrolls from one element to another

Parameters: origin_el – the element from which to begin scrolling (center of element)
des na on_el – the element to scroll to (center of element)
dura on – defines speed of scroll ac on when moving from originalEl to
des na onEl. Default is 600 ms for W3C spec.

Usage:

driver.scroll(el1, el2)

Returns: Self instance


Return type: Union[‘WebDriver’, ‘Ac onHelpers’]

swipe(start_x: int, start_y: int, end_x: int, end_y: int, dura on: int = 0)→ Self

Swipe from one point to another point, for an op onal dura on.

Parameters: start_x – x-coordinate at which to start


start_y – y-coordinate at which to start
end_x – x-coordinate at which to stop
end_y – y-coordinate at which to stop
dura on – defines the swipe speed as me taken to swipe from point a to
point b, in ms.

Usage:

driver.swipe(100, 100, 100, 400)

Returns: Self instance


Return type: Union[‘WebDriver’, ‘Ac onHelpers’]

tap(posi ons: List[Tuple[int, int]], dura on: int | None = None)→ Self

Taps on an par cular place with up to five fingers, holding for a certain me

Parameters: posi ons – an array of tuples represen ng the x/y coordinates of the fingers
to tap. Length can be up to five.
dura on – length of me to tap, in ms

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Usage:

driver.tap([(100, 20), (100, 60), (100, 100)], 500)

Returns: Self instance


Return type: Union[‘WebDriver’, ‘Ac onHelpers’]

webdriver.extensions.applications module

class Applications(*args, **kwargs)

Bases: CanExecuteCommands , CanExecuteScripts , CanRememberExtensionPresence

activate_app(app_id: str)→ Self

Ac vates the applica on if it is not running or is running in the background.

Parameters: app_id – the applica on id to be ac vated


Returns: Self instance
Return type: Union[‘WebDriver’, ‘Applica ons’]

app_strings(language: str | None = None, string_file: str | None = None)→ Dict[str, str]

Returns the applica on strings from the device for the specified language.

Parameters: language – strings language code


string_file – the name of the string file to query. Only relevant for XCUITest
driver
Returns: The key is string id and the value is the content.

background_app(seconds: int)→ Self

Puts the applica on in the background on the device for a certain dura on.

Parameters: seconds – the dura on for the applica on to remain in the background.
app (Providing a nega ve value will con nue immediately a er pu ng the)
background. (under test to the)
Returns: Self instance
Return type: Union[‘WebDriver’, ‘Applica ons’]

install_app(app_path: str, **op ons: Any)→ Self

Install the applica on found at app_path on the device.

Parameters: app_path – the local or remote path to the applica on to install


Keyword Arguments: replace (bool) – [Android only] whether to reinstall/upgrade the packa
if it is already present on the device under test. True by default
meout (int) – [Android only] how much me to wait for the installa
to complete. 60000ms by default.

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
allowTestPackages (bool) – [Android only] whether to allow installa o
of packages marked as test in the manifest. False by default
useSdcard (bool) – [Android only] whether to use the SD card to insta
the app. False by default
grantPermissions (bool) – [Android only] whether to automa cally gra
applica on permissions on Android 6+ a er the installa on complete
False by default
Returns: Self instance
Return type: Union[‘WebDriver’, ‘Applica ons’]

is_app_installed(bundle_id: str)→ bool

Checks whether the applica on specified by bundle_id is installed on the device.

Parameters: bundle_id – the id of the applica on to query


Returns: True if app is installed

query_app_state(app_id: str)→ int

Queries the state of the applica on.

Parameters: app_id – the applica on id to be queried


Returns: One of possible applica on state constants. See Applica onState class for more
details.

remove_app(app_id: str, **op ons: Any)→ Self

Remove the specified applica on from the device.

Parameters: app_id – the applica on id to be removed


Keyword Arguments: keepData (bool) – [Android only] whether to keep applica on data an
caches a er it is uninstalled. False by default
meout (int) – [Android only] how much me to wait for the uninstall
complete. 20000ms by default.
Returns: Self instance
Return type: Union[‘WebDriver’, ‘Applica ons’]

terminate_app(app_id: str, **op ons: Any)→ bool

Terminates the applica on if it is running.

Parameters: app_id – the applica on id to be terminates


Keyword Arguments: meout (int) – [Android only] how much me to wait for the uninstall to
complete. 500ms by default.
Returns: True if the app has been successfully terminated
webdriver.extensions.clipboard module

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
class Clipboard(*args, **kwargs)

Bases: CanExecuteCommands , CanExecuteScripts , CanRememberExtensionPresence

get_clipboard(content_type: str = 'plaintext')→ bytes

Receives the content of the system clipboard

Parameters: content_type – One of ClipboardContentType items. Only


ClipboardContentType.PLAINTEXT is supported on Android
Returns: Clipboard content as bytearray. Or empty bytes if the clipboard is empty

get_clipboard_text()→ str

Receives the text of the system clipboard

Returns: The actual clipboard text or an empty string if the clipboard is empty

set_clipboard(content: bytes, content_type: str = 'plaintext', label: str | None = None)→ Self

Set the content of the system clipboard

Parameters: content – The content to be set as bytearray string


content_type – One of ClipboardContentType items. Only
ClipboardContentType.PLAINTEXT is supported on Android
label – label argument, which only works for Android
Returns: Self instance
Return type: Union[‘WebDriver’, ‘Clipboard’]

set_clipboard_text(text: str, label: str | None = None)→ Self

Copies the given text to the system clipboard

Parameters: text – The text to be set


label – label argument, which only works for Android
Returns: Self instance
Return type: Union[‘WebDriver’, ‘Clipboard’]

webdriver.extensions.context module

class Context(*args, **kwargs)

Bases: CanExecuteCommands

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
property context: str

Returns the current context of the current session.

Usage:

driver.context

Returns: The context of the current session


Return type: str

property contexts: List[str]

Returns the contexts within the current session.

Usage:

driver.contexts

Returns: The contexts within the current session


Return type: list of str

property current_context: str

Returns the current context of the current session.

Usage:

driver.current_context

Returns: The context of the current session


Return type: str

webdriver.extensions.device_time module

class DeviceTime(*args, **kwargs)

Bases: CanExecuteCommands , CanExecuteScripts , CanRememberExtensionPresence

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
property device_time: str

Returns the date and me from the device.

Returns: The date and me


Return type: str

get_device_time(format: str | None = None)→ str

Returns the date and me from the device.

Parameters: format – The set of format specifiers. Read h ps://momentjs.com/docs/ to get


the full list of supported date me format specifiers. If unset, return
device_time() as default format is YYYY-MM-DDTHH:mm:ssZ, which complies to

ISO-8601

Usage:
self.driver.get_device_ me()
self.driver.get_device_ me(“YYYY-MM-DD”)

Returns: The date and me


Return type: str
webdriver.extensions.execute_driver module

class ExecuteDriver(*args, **kwargs)

Bases: CanExecuteCommands

execute_driver(script: str, script_type: str = 'webdriverio', meout_ms: int | None = None)→ Any

Run a set of script against the current session, allowing execu on of many commands in one
Appium request. Please read h p://appium.io/docs/en/commands/session/execute-driver for more
details about the acceptable scripts and the output format.

Parameters: script – The string consis ng of the script itself


script_type – The name of the script type. Defaults to ‘webdriverio’.
meout_ms – The number of ms Appium should wait for the script to finish
before killing it due to meout_ms.

Usage:
self.driver.execute_driver(script=’return [];’)
self.driver.execute_driver(script=’return [];’, script_type=’webdriverio’)
self.driver.execute_driver(script=’return [];’, script_type=’webdriverio’, meout_ms=10000)

Returns: The result of the script. It has ‘result’ and ‘logs’ keys.

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Return type: ExecuteDriver.Result
Raises: WebDriverExcep on – If something error happenes in the script. The message
has the original error message.

webdriver.extensions.execute_mobile_command module

class ExecuteMobileCommand(*args, **kwargs)

Bases: CanExecuteScripts

property battery_info: Dict[str, Any]

Retrieves ba ery informa on for the device under test.

Returns:
containing the following entries

level: Ba ery level in range [0.0, 1.0], where 1.0 means 100% charge.

Any value lower than 0 means the level cannot be retrieved

state: Pla orm-dependent ba ery state value.

On iOS (XCUITest):

1: Unplugged 2: Charging 3: Full Any other value means the state


cannot be retrieved

On Android (UIAutomator2):

2: Charging 3: Discharging 4: Not charging 5: Full Any other value


means the state cannot be retrieved

Return type: dict

press_button(bu on_name: str)→ Self

Sends a physical bu on name to the device to simulate the user pressing.

iOS only. Possible bu on names can be found in


h ps://github.com/appium/WebDriverAgent/blob/master/WebDriverAgentLib/Categories/XCUID
evice%2BFBHelpers.h

Parameters: bu on_name – the bu on name to be sent to the device


Returns: Self instance
Return type: Union[‘WebDriver’, ‘ExecuteMobileCommand’]

webdriver.extensions.hw_actions module

class HardwareActions(*args, **kwargs)

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Bases: CanExecuteCommands , CanExecuteScripts , CanRememberExtensionPresence

finger_print(finger_id: int)→ Self

Authen cate users by using their finger print scans on supported Android emulators.

Parameters: finger_id – Finger prints stored in Android Keystore system (from 1 to 10)

is_locked()→ bool

Checks whether the device is locked.

Returns: True if the device is locked

lock(seconds: int | None = None)→ Self

Lock the device. No changes are made if the device is already unlocked.

Parameters: seconds – The dura on to lock the device, in seconds. The device is going to be
locked forever un l unlock is called if it equals or is less than zero, otherwise this
call blocks un l the meout expires and unlocks the screen automa cally.
Returns: Self instance
Return type: Union[‘WebDriver’, ‘HardwareAc ons’]

shake()→ Self

Shake the device.

Returns: Self instance


Return type: Union[‘WebDriver’, ‘HardwareAc ons’]

toggle_touch_id_enrollment()→ Self

Toggle enroll touchId on iOS Simulator

Returns: Self instance


Return type: Union[‘WebDriver’, ‘HardwareAc ons’]

touch_id(match: bool)→ Self

Simulate touchId on iOS Simulator

Parameters: match – Simulates a successful touch (True) or a failed touch (False)


Returns: Self instance
Return type: Union[‘WebDriver’, ‘HardwareAc ons’]

unlock()→ Self

Unlock the device. No changes are made if the device is already locked.

Returns: Self instance

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Return type: Union[‘WebDriver’, ‘HardwareAc ons’]

webdriver.extensions.images_comparison module

class ImagesComparison(*args, **kwargs)

Bases: CanExecuteCommands

find_image_occurrence(base64_full_image: bytes, base64_par al_image: bytes, **opts: Any)→ Dict[str, bytes


| Dict]

Performs images matching by template to find possible occurrence of the par al image in the full
image.

Read
h ps://docs.opencv.org/2.4/doc/tutorials/imgproc/histograms/template_matching/template_matc
hing.html for more details on this topic. The method supports all image formats, which are
supported by OpenCV itself.

Parameters: base64_full_image – base64-encoded content of the full image


base64_par al_image – base64-encoded content of the par al image
Keyword Arguments: visualize (bool) – Set it to True in order to return the visualiza on of the
matching opera on. False by default
Returns:
visualiza on (bytes): base64-encoded content of PNG visualiza on of th
current comparison

opera on. This entry is only present if visualize op on is enabled

rect (dict): The region of the par al image occurrence on the full image.

The rect is represented by a dic onary with ‘x’, ‘y’, ‘width’ and ‘height’
keys

Return type: The dic onary containing the following entries

get_images_similarity(base64_image1: bytes, base64_image2: bytes, **opts: Any)→ Dict[str, bytes | Dict]

Performs images matching to calculate the similarity score between them.

The flow there is similar to the one used in find_image_occurrence, but it is mandatory that both
images are of equal resolu on. The method supports all image formats, which are supported by
OpenCV itself.

Parameters: base64_image1 – base64-encoded content of the first image


base64_image2 – base64-encoded content of the second image
Keyword Arguments: visualize (boo) – Set it to True in order to return the visualiza on of the
matching opera on. False by default
Returns:

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
visualiza on (bytes): base64-encoded content of PNG visualiza on of th
current comparison

opera on. This entry is only present if visualize op on is enabled

score (float): The similarity score as a float number in range [0.0, 1.0].

1.0 is the highest score (means both images are totally equal).

Return type: The dic onary containing the following entries

match_images_features(base64_image1: bytes, base64_image2: bytes, **opts: Any)→ Dict[str, Any]

Performs images matching by features.

Read h ps://docs.opencv.org/3.0-
beta/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.html for more details on this topic.
The method supports all image formats, which are supported by OpenCV itself.

Parameters: base64_image1 – base64-encoded content of the first image


base64_image2 – base64-encoded content of the second image
Keyword Arguments: visualize (bool) – Set it to True in order to return the visualiza on of th
matching opera on. matching visualiza on. False by default
detectorName (str) – One of possible feature detector names: ‘AKAZ
‘AGAST’, ‘BRISK’, ‘FAST’, ‘GFTT’, ‘KAZE’, ‘MSER’, ‘SIFT’, ‘ORB’ Some of
these detectors are not enabled in the default OpenCV deployment.
‘ORB’ By default.
matchFunc (str) – One of supported matching func ons names:
‘FlannBased’, ‘BruteForce’, ‘BruteForceL1’, ‘BruteForceHamming’,
‘BruteForceHammingLut’, ‘BruteForceSL2’ ‘BruteForce’ by default
goodMatchesFactor (int) – The maximum count of “good” matches (e.
with minimal distances). This count is unlimited by default.
Returns:
visualiza on (bytes): base64-encoded content of PNG visualiza on of th
current comparison

opera on. This entry is only present if visualize op on is enabled

count (int): The count of matched edges on both images.

The more matching edges there are no both images the more similar
they are.

totalCount (int): The total count of matched edges on both images.

It is equal to count if goodMatchesFactor does not limit the matches,


otherwise it contains the total count of matches before
goodMatchesFactor is applied.

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
points1 (dict): The array of matching points on the first image. Each poin
a dic onary

with ‘x’ and ‘y’ keys

rect1 (dict): The bounding rect for the points1 array or a zero rect if not
enough matching points

were found. The rect is represented by a dic onary with ‘x’, ‘y’, ‘width’
and ‘height’ keys

points2 (dict): The array of matching points on the second image. Each
point is a dic onary

with ‘x’ and ‘y’ keys

rect2 (dict): The bounding rect for the points2 array or a zero rect if not
enough matching points

were found. The rect is represented by a dic onary with ‘x’, ‘y’, ‘width’
and ‘height’ keys

Return type: The dic onary containing the following entries


webdriver.extensions.keyboard module

class Keyboard(*args, **kwargs)

Bases: CanExecuteCommands , CanExecuteScripts , CanRememberExtensionPresence

hide_keyboard(key_name: str | None = None, key: str | None = None, strategy: str | None = None)→ Self

Hides the so ware keyboard on the device.

In iOS, use key_name to press a par cular key, or strategy. In Android, no parameters are used.

Parameters: key_name – key to press


key
strategy – strategy for closing the keyboard (e.g., tapOutside)
Returns: Self instance
Return type: Union[‘WebDriver’, ‘Keyboard’]

is_keyboard_shown()→ bool

A empts to detect whether a so ware keyboard is present

Returns: True if keyboard is shown

keyevent(keycode: int, metastate: int | None = None)→ Self

Sends a keycode to the device.

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Android only. Possible keycodes can be found in
h p://developer.android.com/reference/android/view/KeyEvent.html.

Parameters: keycode – the keycode to be sent to the device


metastate – meta informa on about the keycode being sent
Returns: Self instance
Return type: Union[‘WebDriver’, ‘Keyboard’]

long_press_keycode(keycode: int, metastate: int | None = None, flags: int | None = None)→ Self

Sends a long press of keycode to the device.

Android only. Possible keycodes can be found in


h p://developer.android.com/reference/android/view/KeyEvent.html.

Parameters: keycode – the keycode to be sent to the device


metastate – meta informa on about the keycode being sent
flags – the set of key event flags
Returns: Self instance
Return type: Union[‘WebDriver’, ‘Keyboard’]

press_keycode(keycode: int, metastate: int | None = None, flags: int | None = None)→ Self

Sends a keycode to the device.

Android only. Possible keycodes can be found in


h p://developer.android.com/reference/android/view/KeyEvent.html.

Parameters: keycode – the keycode to be sent to the device


metastate – meta informa on about the keycode being sent
flags – the set of key event flags
Returns: Self instance
Return type: Union[‘WebDriver’, ‘Keyboard’]

webdriver.extensions.location module

class Location(*args, **kwargs)

Bases: CanExecuteCommands , CanExecuteScripts

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
property location: Dict[str, float]

Retrieves the current loca on

Returns:
A dic onary whose keys are

la tude (float)
longitude (float)
al tude (float)

set_location(la tude: float | str, longitude: float | str, al tude: float | str | None = None, speed: float | str | None
= None, satellites: float | str | None = None)→ Self

Set the loca on of the device

Parameters: la tude – String or numeric value between -90.0 and 90.00


longitude – String or numeric value between -180.0 and 180.0
al tude – String or numeric value (Android real device only)
speed – String or numeric value larger than 0.0 (Android real devices only)
satellites – String or numeric value of ac ve GPS satellites in range 1..12.
(Android emulators only)
Returns: Self instance
Return type: Union[‘WebDriver’, ‘Loca on’]

toggle_location_services()→ Self

Toggle the loca on services on the device. This API only reliably since Android 12 (API level 31)

Android only.

Returns: Self instance


Return type: Union[‘WebDriver’, ‘Loca on’]
webdriver.extensions.log_event module

class LogEvent(*args, **kwargs)

Bases: CanExecuteCommands

get_events(type: List[str] | None = None)→ Dict[str, str | int]

Retrieves events informa on from the current session (Since Appium 1.16.0)

Parameters: type – The event type to filter with

Usage:
events = driver.get_events()

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
events = driver.get_events([‘appium:funEvent’])

Returns:
A dic onary of events ming informa on containing the following entries
commands: (list of dict) List of dic onaries containing the following entries
cmd: The command name that has been sent to the appium server
startTime: Received me
endTime: Response me

Return type: dict

log_event(vendor: str, event: str)→ Self

Log a custom event on the Appium server. (Since Appium 1.16.0)

Parameters: vendor – The vendor to log


event – The event to log

Usage:

driver.log_event(‘appium’, ‘funEvent’)

Returns: Self instance


Return type: Union[‘WebDriver’, ‘LogEvent’]

webdriver.extensions.remote_fs module

class RemoteFS(*args, **kwargs)

Bases: CanExecuteCommands , CanExecuteScripts , CanRememberExtensionPresence

pull_file(path: str)→ str

Retrieves the file at path.

Parameters: path – the path to the file on the device


Returns: The file’s contents encoded as Base64.

pull_folder(path: str)→ str

Retrieves a folder at path.

Parameters: path – the path to the folder on the device


Returns: The folder’s contents zipped and encoded as Base64.

push_file(des na on_path: str, base64data: str | None = None, source_path: str | None = None)→ Self

Puts the data from the file at source_path, encoded as Base64, in the file specified as path.

Specify either base64data or source_path, if both specified default to source_path

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Parameters: des na on_path – the loca on on the device/simulator where the local file
contents should be saved
base64data – file contents, encoded as Base64, to be wri en
device/simulator (to the file on the)
source_path – local file path for the file to be loaded on device
Returns: Self instance
Return type: Union[‘WebDriver’, ‘RemoteFS’]
webdriver.extensions.screen_record module

class ScreenRecord(*args, **kwargs)

Bases: CanExecuteCommands

start_recording_screen(**op ons: Any)→ bytes | str

Start asynchronous screen recording process.

Keyword Args iOS Android Win macOS

remotePath O O O O

user O O O O

password O O O O

method O O O O

meLimit O O O O

forceRestart O O O O

fileFieldName O O O O

formFields O O O O

headers O O O O

videoQuality O

videoType O

videoFps O

videoFilter O O O

videoScale O

pixelFormat O

videoSize O

bitRate O

bugReport O

fps O O

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Keyword Args iOS Android Win macOS

captureCursor O O

captureClicks O O

deviceId O

preset O O

audioInput O

Keyword Arguments: remotePath (str) – The remotePath upload op on is the path to the
remote loca on, where the resul ng video from the previous screen
recording should be uploaded. The following protocols are supported
h p/h ps (mul part), p. Missing value (the default se ng) means th
content of the resul ng file should be encoded as Base64 and passed
the endpoint response value, but an excep on will be thrown if the
generated media file is too big to fit into the available process memor
This op on only has an effect if there is/was an ac ve screen recordin
session and forced restart is not enabled (the default se ng).
user (str) – The name of the user for the remote authen ca on. Only
an effect if both remotePath and password are set.
password (str) – The password for the remote authen ca on. Only ha
an effect if both remotePath and user are set.
method (str) – The HTTP method name (‘PUT’/’POST’). PUT method i
used by default. Only has an effect if remotePath is set.
meLimit (int) – The actual me limit of the recorded video in second
The default value for both iOS and Android is 180 seconds (3 minutes
The default value for macOS is 600 seconds (10 minutes). The maxim
value for Android is 3 minutes. The maximum value for iOS is 10
minutes. The maximum value for macOS is 10000 seconds (166
minutes).
forcedRestart (bool) – Whether to ignore the result of previous captu
and start a new recording immediately (True value). By default (False) t
endpoint will try to catch and return the result of the previous captur
it’s s ll available.
fileFieldName (str) – [mul part/form-data requests] The name of the
form field containing the binary payload. “file” by default. (Since Appiu
1.18.0)
formFields (dict) – [mul part/form-data requests] Addi onal form fiel
mapping. If any entry has the same key as fileFieldName then it is goin
to be ignored. (Since Appium 1.18.0)
headers (dict) – [mul part/form-data requests] Headers mapping (Sin
Appium 1.18.0)

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
videoQuality (str) – [iOS] The video encoding quality: ‘low’, ‘medium’,
‘high’, ‘photo’. Defaults to ‘medium’.
videoType (str) – [iOS] The format of the screen capture to be recorde
Available formats: Execute ffmpeg -codecs in the terminal to see the li
of supported video codecs. ‘mjpeg’ by default. (Since Appium 1.10.0)
videoFps (int) – [iOS] The Frames Per Second rate of the recorded vid
Change this value if the resul ng video is too slow or too fast. Defaul
to 10. This can decrease the resul ng file size.
videoFilters (str) – [iOS, Win, macOS] The FFMPEG video filters to
apply. These filters allow to scale, flip, rotate and do many other usefu
transforma ons on the source video stream. The format of the prope
must comply with h ps://ffmpeg.org/ffmpeg-filters.html. (Since Appiu
1.15)
videoScale (str) – [iOS] The scaling value to apply. Read
h ps://trac.ffmpeg.org/wiki/Scaling for possible values. No scale is
applied by default. If videoFilters are set then the scale se ng is
effec vely ignored. (Since Appium 1.10.0)
pixelFormat (str) – [iOS] Output pixel format. Run ffmpeg -pix_fmts to
possible values. For Quick me compa bility, set to “yuv420p” along
with videoType: “libx264”. (Since Appium 1.12.0)
videoSize (str) – [Android] The video size of the generated media file.
The format is WIDTHxHEIGHT. The default value is the device’s na v
display resolu on (if supported), 1280x720 if not. For best results, us
size supported by your device’s Advanced Video Coding (AVC) encode
bitRate (int) – [Android] The video bit rate for the video, in megabits p
second. The default value is 4. You can increase the bit rate to improv
video quality, but doing so results in larger movie files.
bugReport (str) – [Android] Makes the recorder to display an addi on
informa on on the video overlay, such as a mestamp, that is helpful
videos captured to illustrate bugs. This op on is only supported since
API level 27 (Android P).
fps (int) – [Win, macOS] The count of frames per second in the resul
video. Increasing fps value also increases the size of the resul ng vide
file and the CPU usage.
captureCursor (bool) – [Win, macOS] Whether to capture the mouse
cursor while recording the screen. Disabled by default.
captureClick (bool) – [Win, macOS] Whether to capture the click
gestures while recording the screen. Disabled by default.
deviceId (int) – [macOS] Screen device index to use for the recording.
The list of available devices could be retrieved using ffmpeg -f
avfounda on -list_devices true -i command. This op on is mandatory a
must be always provided.
preset (str) – [Win, macOS] A preset is a collec on of op ons that wil
provide a certain encoding speed to compression ra o. A slower pres

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
will provide be er compression (compression is quality per filesize). T
means that, for example, if you target a certain file size or constant bi
rate, you will achieve be er quality with a slower preset. Read
h ps://trac.ffmpeg.org/wiki/Encode/H.264 for more details. Possible
values are ‘ultrafast’, ‘superfast’, ‘veryfast’(default), ‘faster’, ‘fast’,
‘medium’, ‘slow’, ‘slower’, ‘veryslow’
Returns:
Base-64 encoded content of the recorded media

if stop_recording_screen isn’t called a er previous start_recording_scree


Otherwise returns an empty string.

Return type: bytes

stop_recording_screen(**op ons: Any)→ bytes

Gather the output from the previously started screen recording to a media file.

Keyword Arguments: remotePath (str) – The remotePath upload op on is the path to the
remote loca on, where the resul ng video should be uploaded. The
following protocols are supported: h p/h ps (mul part), p. Missing
value (the default se ng) means the content of the resul ng file shou
be encoded as Base64 and passed as the endpoint response value, bu
an excep on will be thrown if the generated media file is too big to fit
into the available process memory.
user (str) – The name of the user for the remote authen ca on. Only
an effect if both remotePath and password are set.
password (str) – The password for the remote authen ca on. Only ha
an effect if both remotePath and user are set.
method (str) – The HTTP method name (‘PUT’/’POST’). PUT method i
used by default. Only has an effect if remotePath is set.
fileFieldName (str) – [mul part/form-data requests] The name of the
form field containing the binary payload. “file” by default. (Since Appiu
1.18.0)
formFields (dict) – [mul part/form-data requests] Addi onal form fiel
mapping. If any entry has the same key as fileFieldName then it is goin
to be ignored. (Since Appium 1.18.0)
headers (dict) – [mul part/form-data requests] Headers mapping (Sin
Appium 1.18.0)
Returns:
Base-64 encoded content of the recorded media file or an empty string

if the file has been successfully uploaded to a remote loca on (depen


on the actual remotePath value).

Return type: bytes

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
webdriver.extensions.session module

class Session(*args, **kwargs)

Bases: CanExecuteCommands

property events: Dict

Retrieves events informa on from the current session

Usage:

events = driver.events

Returns: containing events ming informa on from the current session


Return type: dict

webdriver.extensions.settings module

class Settings(*args, **kwargs)

Bases: CanExecuteCommands

get_settings()→ Dict[str, Any]

Returns the appium server Se ngs for the current session.

Do not get Se ngs confused with Desired Capabili es, they are separate concepts. See
h ps://github.com/appium/appium/blob/master/docs/en/advanced-concepts/se ngs.md

Returns: Current se ngs

update_settings(se ngs: Dict[str, Any])→ Self

Set se ngs for the current session.

For more on se ngs, see: h ps://github.com/appium/appium/blob/master/docs/en/advanced-


concepts/se ngs.md

Parameters: se ngs – dic onary of se ngs to apply to the current test session

Module contents

Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF

You might also like