webdriver.extensions package#

Subpackages#

Submodules#

webdriver.extensions.action_helpers module#

class ActionHelpers#

Bases: object

drag_and_drop(origin_el: WebElement, destination_el: WebElement, pause: float | None = None) → Self#

Drag the origin element to the destination element

Deprecated since version Please: use W3C actions (ActionChains / ActionBuilder) or driver-specific mobile: gesture extensions instead.

Parameters:
  • origin_el – the element to drag

  • destination_el – the element to drag to

  • pause – how long the action pauses before moving after the tap and hold, in float seconds.

Returns:

Self instance

Return type:

Union[‘WebDriver’, ‘ActionHelpers’]

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

Flick from one point to another point.

Deprecated since version Please: use W3C actions (ActionChains / ActionBuilder) or driver-specific mobile: gesture extensions instead.

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

Usage:

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

Returns:

Self instance

Return type:

Union[‘WebDriver’, ‘ActionHelpers’]

scroll(origin_el: WebElement, destination_el: WebElement, duration: int | None = None) → Self#

Scrolls from one element to another

Deprecated since version Please: use W3C actions (ActionChains / ActionBuilder) or driver-specific mobile: gesture extensions instead.

Parameters:
  • origin_el – the element from which to begin scrolling (center of element)

  • destination_el – the element to scroll to (center of element)

  • duration – defines speed of scroll action when moving from originalEl to destinationEl. Default is 600 ms for W3C spec.

Usage:

driver.scroll(el1, el2)

Returns:

Self instance

Return type:

Union[‘WebDriver’, ‘ActionHelpers’]

swipe(start_x: int, start_y: int, end_x: int, end_y: int, duration: int = 0) → Self#

Swipe from one point to another point, for an optional duration.

Deprecated since version Please: use W3C actions (ActionChains / ActionBuilder) or driver-specific mobile: gesture extensions instead.

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

  • duration – defines the swipe speed as time 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’, ‘ActionHelpers’]

tap(positions: list[tuple[int, int]], duration: int | None = None) → Self#

Taps on an particular place with up to five fingers, holding for a certain time

Deprecated since version Please: use W3C actions (ActionChains / ActionBuilder) or driver-specific mobile: gesture extensions instead.

Parameters:
  • positions – an array of tuples representing the x/y coordinates of the fingers to tap. Length can be up to five.

  • duration – length of time to tap, in ms

Usage:

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

Returns:

Self instance

Return type:

Union[‘WebDriver’, ‘ActionHelpers’]

webdriver.extensions.applications module#

class Applications(*args, **kwargs)#

Bases: CanExecuteCommands, CanExecuteScripts

activate_app(app_id: str) → Self#

Activates the application if it is not running or is running in the background.

Parameters:

app_id – the application id to be activated

Returns:

Self instance

Return type:

Union[‘WebDriver’, ‘Applications’]

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

Returns the application 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 application in the background on the device for a certain duration.

Parameters:
  • seconds – the duration for the application to remain in the background.

  • app (Providing a negative value will continue immediately after putting the)

  • background. (under test to the)

Returns:

Self instance

Return type:

Union[‘WebDriver’, ‘Applications’]

install_app(app_path: str, **options: Any) → Self#

Install the application found at app_path on the device.

Parameters:

app_path – the local or remote path to the application to install

Keyword Arguments:
  • replace (bool) – [Android only] whether to reinstall/upgrade the package if it is already present on the device under test. True by default

  • timeout (int) – [Android only] how much time to wait for the installation to complete. 60000ms by default.

  • allowTestPackages (bool) – [Android only] whether to allow installation of packages marked as test in the manifest. False by default

  • useSdcard (bool) – [Android only] whether to use the SD card to install the app. False by default

  • grantPermissions (bool) – [Android only] whether to automatically grant application permissions on Android 6+ after the installation completes. False by default

Returns:

Self instance

Return type:

Union[‘WebDriver’, ‘Applications’]

is_app_installed(bundle_id: str) → bool#

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

Parameters:

bundle_id – the id of the application to query

Returns:

True if app is installed

query_app_state(app_id: str) → int#

Queries the state of the application.

Parameters:

app_id – the application id to be queried

Returns:

One of possible application state constants. See ApplicationState class for more details.

remove_app(app_id: str, **options: Any) → Self#

Remove the specified application from the device.

Parameters:

app_id – the application id to be removed

Keyword Arguments:
  • keepData (bool) – [Android only] whether to keep application data and caches after it is uninstalled. False by default

  • timeout (int) – [Android only] how much time to wait for the uninstall to complete. 20000ms by default.

Returns:

Self instance

Return type:

Union[‘WebDriver’, ‘Applications’]

terminate_app(app_id: str, **options: Any) → bool#

Terminates the application if it is running.

Parameters:

app_id – the application id to be terminates

Keyword Arguments:

timeout (int) – [Android only] how much time to wait for the uninstall to complete. 500ms by default.

Returns:

True if the app has been successfully terminated

webdriver.extensions.clipboard module#

class Clipboard(*args, **kwargs)#

Bases: CanExecuteCommands, CanExecuteScripts

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

Receives the content of the system clipboard

Requires the Appium driver to support the mobile: getClipboard execute method.

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

Requires the Appium driver to support the mobile: getClipboard execute method.

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

Requires the Appium driver to support the mobile: setClipboard execute method.

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

Requires the Appium driver to support the mobile: setClipboard execute method.

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

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

property device_time: str#

Returns the date and time from the device.

Requires the Appium driver to support the mobile: getDeviceTime execute method.

Returns:

The date and time

Return type:

str

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

Returns the date and time from the device.

Requires the Appium driver to support the mobile: getDeviceTime execute method.

Parameters:

format – The set of format specifiers. Read https://momentjs.com/docs/ to get the full list of supported datetime 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_time()
self.driver.get_device_time(“YYYY-MM-DD”)
Returns:

The date and time

Return type:

str

webdriver.extensions.execute_driver module#

class ExecuteDriver(*args, **kwargs)#

Bases: CanExecuteCommands

class Result(res: dict[str, Any])#

Bases: object

The result of execute_driver, containing result and logs.

logs: dict[str, list[Any]]#
result: Any#
execute_driver(script: str, script_type: str = 'webdriverio', timeout_ms: int | None = None) → Result#

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

Parameters:
  • script – The string consisting of the script itself

  • script_type – The name of the script type. Defaults to ‘webdriverio’.

  • timeout_ms – The number of ms Appium should wait for the script to finish before killing it due to timeout_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’, timeout_ms=10000)
Returns:

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

Return type:

ExecuteDriver.Result

Raises:

WebDriverException – If something error happens 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 battery information for the device under test.

Returns:

containing the following entries
level: Battery 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: Platform-dependent battery 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(button_name: str) → Self#

Sends a physical button name to the device to simulate the user pressing.

iOS only. Possible button names can be found in appium/WebDriverAgent

Parameters:

button_name – the button name to be sent to the device

Returns:

Self instance

Return type:

Union[‘WebDriver’, ‘ExecuteMobileCommand’]

webdriver.extensions.hw_actions module#

class HardwareActions(*args, **kwargs)#

Bases: CanExecuteCommands, CanExecuteScripts

finger_print(finger_id: int) → Self#

Authenticate users using a fingerprint scan on supported Android emulators.

Requires the Appium driver to support the mobile: fingerprint execute method.

Parameters:

finger_id – Fingerprint identifier stored in the Android Keystore system (from 1 to 10)

Returns:

Self instance

Return type:

Union[‘WebDriver’, ‘HardwareActions’]

is_locked() → bool#

Checks whether the device is locked.

Requires the Appium driver to support the mobile: isLocked execute method.

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 locked.

Requires the Appium driver to support the mobile: lock execute method.

Parameters:

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 call blocks until the timeout expires and unlocks the screen automatically.

Returns:

Self instance

Return type:

Union[‘WebDriver’, ‘HardwareActions’]

shake() → Self#

Shake the device.

Requires the Appium driver to support the mobile: shake execute method.

Returns:

Self instance

Return type:

Union[‘WebDriver’, ‘HardwareActions’]

toggle_touch_id_enrollment() → Self#

Toggle enroll touchId on iOS Simulator

Returns:

Self instance

Return type:

Union[‘WebDriver’, ‘HardwareActions’]

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’, ‘HardwareActions’]

unlock() → Self#

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

Requires the Appium driver to support the mobile: isLocked and mobile: unlock execute methods.

Returns:

Self instance

Return type:

Union[‘WebDriver’, ‘HardwareActions’]

webdriver.extensions.images_comparison module#

class ImagesComparison(*args, **kwargs)#

Bases: CanExecuteCommands

find_image_occurrence(base64_full_image: str | bytes, base64_partial_image: str | bytes, **opts: Any) → dict[str, Any] | list[dict[str, Any]]#

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

Read https://docs.opencv.org/2.4/doc/tutorials/imgproc/histograms/template_matching/template_matching.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_partial_image – base64-encoded content of the partial image

Keyword Arguments:
  • visualize (bool) – Set it to True in order to return the visualization of the matching operation. False by default

  • multiple (bool) – Set it to True in order to return all matches above the threshold as a list. False by default

Returns:

The dictionary containing the following entries, or a list of such dictionaries (one per match) if multiple is enabled:

  • visualization (str): base64-encoded PNG, present when visualize is enabled.

  • rect (dict): region of the match with x, y, width and height keys.

  • score (float): similarity score of the match.

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

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 resolution. 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 visualization of the matching operation. False by default

Returns:

visualization (str): base64-encoded content of PNG visualization of the current comparison

operation. This entry is only present if visualize option 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 dictionary containing the following entries

match_images_features(base64_image1: str | bytes, base64_image2: str | bytes, **opts: Any) → dict[str, Any]#

Performs images matching by features.

Read https://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 visualization of the matching operation. matching visualization. False by default

  • detectorName (str) – One of possible feature detector names: ‘AKAZE’, ‘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 functions names: ‘FlannBased’, ‘BruteForce’, ‘BruteForceL1’, ‘BruteForceHamming’, ‘BruteForceHammingLut’, ‘BruteForceSL2’ ‘BruteForce’ by default

  • goodMatchesFactor (int) – The maximum count of “good” matches (e. g. with minimal distances). This count is unlimited by default.

Returns:

visualization (str): base64-encoded content of PNG visualization of the current comparison

operation. This entry is only present if visualize option 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.

points1 (list): The array of matching points on the first image. Each point is a dictionary

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 dictionary with ‘x’, ‘y’, ‘width’ and ‘height’ keys

points2 (list): The array of matching points on the second image. Each point is a dictionary

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 dictionary with ‘x’, ‘y’, ‘width’ and ‘height’ keys

Return type:

The dictionary containing the following entries

webdriver.extensions.keyboard module#

class Keyboard(*args, **kwargs)#

Bases: CanExecuteCommands, CanExecuteScripts

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

Hides the software keyboard on the device.

On iOS, use key_name or key to provide a keyboard key name. On Android, no parameters are used. strategy is retained for compatibility and ignored.

Requires the Appium driver to support the mobile: hideKeyboard execute method.

Parameters:
  • key_name – Keyboard key name to use on iOS

  • key – Alias for key_name

  • strategy – Legacy argument retained for compatibility; ignored by mobile: hideKeyboard

Returns:

Self instance

Return type:

Union[‘WebDriver’, ‘Keyboard’]

is_keyboard_shown() → bool#

Attempts to detect whether a software keyboard is present

Requires the Appium driver to support the mobile: isKeyboardShown execute method.

Returns:

True if keyboard is shown

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

Sends a keycode to the device.

Android only. Possible keycodes can be found in http://developer.android.com/reference/android/view/KeyEvent.html.

Requires the Appium driver to support the mobile: pressKey execute method.

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

  • metastate – meta information 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 http://developer.android.com/reference/android/view/KeyEvent.html.

Requires the Appium driver to support the mobile: pressKey execute method.

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

  • metastate – meta information 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 http://developer.android.com/reference/android/view/KeyEvent.html.

Requires the Appium driver to support the mobile: pressKey execute method.

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

  • metastate – meta information 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

property location: dict[str, float]#

Retrieves the current location

Returns:

A dictionary whose keys are
  • latitude (float)

  • longitude (float)

  • altitude (float)

set_location(latitude: float | str, longitude: float | str, altitude: float | str | None = None, speed: float | str | None = None, satellites: float | str | None = None) → Self#

Set the location of the device

Parameters:
  • latitude – String or numeric value between -90.0 and 90.00

  • longitude – String or numeric value between -180.0 and 180.0

  • altitude – 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 active GPS satellites in range 1..12. (Android emulators only)

Returns:

Self instance

Return type:

Union[‘WebDriver’, ‘Location’]

toggle_location_services() → Self#

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

Android only.

Returns:

Self instance

Return type:

Union[‘WebDriver’, ‘Location’]

webdriver.extensions.log_event module#

class LogEvent(*args, **kwargs)#

Bases: CanExecuteCommands

get_events(type: list[str] | None = None) → dict[str, Any]#

Retrieves events information from the current session (Since Appium 1.16.0)

Parameters:

type – The event type to filter with

Usage:
events = driver.get_events()
events = driver.get_events([‘appium:funEvent’])
Returns:

A dictionary of events timing information. Every value is a list.
commands: (list of dict) List of dictionaries containing the following entries
cmd: The command name that has been sent to the appium server
startTime: Received time
endTime: Response time
Each other key is an event name, such as ‘appium:funEvent’, and its value is
the list of timestamps (int, milliseconds) when that event happened

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.logs module#

class Logs(*args, **kwargs)#

Bases: CanExecuteCommands

get_log(log_type: str) → list[dict[str, Any]]#

Gets the log for a given log type.

Parameters:

log_type – Type of log that which will be returned

Example

driver.get_log('browser')
driver.get_log('driver')
driver.get_log('client')
driver.get_log('server')
property log_types: list[str]#

Gets a list of the available log types. This only works with w3c compliant browsers.

Example

driver.log_types

webdriver.extensions.remote_fs module#

class RemoteFS(*args, **kwargs)#

Bases: CanExecuteCommands, CanExecuteScripts

pull_file(path: str) → str#

Retrieves the file at path.

Requires the Appium driver to support the mobile: pullFile execute method.

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.

Requires the Appium driver to support the mobile: pullFolder execute method.

Parameters:

path – the path to the folder on the device

Returns:

The folder’s contents zipped and encoded as Base64.

push_file(destination_path: str, base64data: str | None = None, source_path: str | None = None) → Self#

Puts the data from the file at source_path, encoded as Base64, at destination_path.

Specify either base64data or source_path. If both are provided, source_path takes precedence.

Requires the Appium driver to support the mobile: pushFile execute method.

Parameters:
  • destination_path – the location on the device/simulator where the local file contents should be saved

  • base64data – file contents, encoded as Base64, to be written to the file on the device/simulator

  • 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(**options: Any) → str | None#

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

timeLimit

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

videoFilters

O

videoFilter

O

O

videoScale

O

pixelFormat

O

videoSize

O

bitRate

O

bugReport

O

fps

O

O

captureCursor

O

O

captureClicks

O

O

deviceId

O

preset

O

O

audioInput

O

Keyword Arguments:
  • remotePath (str) – The remotePath upload option is the path to the remote location, where the resulting video from the previous screen recording should be uploaded. The following protocols are supported: http/https (multipart), ftp. Missing value (the default setting) means the content of the resulting file should be encoded as Base64 and passed as the endpoint response value, but an exception will be thrown if the generated media file is too big to fit into the available process memory. This option only has an effect if there is/was an active screen recording session and forced restart is not enabled (the default setting).

  • user (str) – The name of the user for the remote authentication. Only has an effect if both remotePath and password are set.

  • password (str) – The password for the remote authentication. Only has an effect if both remotePath and user are set.

  • method (str) – The HTTP method name (‘PUT’/’POST’). PUT method is used by default. Only has an effect if remotePath is set.

  • timeLimit (int) – The actual time limit of the recorded video in seconds. The default value for both iOS and Android is 180 seconds (3 minutes). The default value for Windows and macOS is 600 seconds (10 minutes). The maximum value for Android is 1800 seconds (30 minutes). The maximum value for iOS is 4200 seconds (70 minutes).

  • forceRestart (bool) – Whether to ignore the result of previous capture and start a new recording immediately (True value). By default (False) the endpoint will try to catch and return the result of the previous capture if it’s still available. On Windows and macOS the default is True, and False makes the call do nothing while a recording is already running.

  • fileFieldName (str) – [multipart/form-data requests] The name of the form field containing the binary payload. “file” by default. (Since Appium 1.18.0)

  • formFields (dict) – [multipart/form-data requests] Additional form fields mapping. If any entry has the same key as fileFieldName then it is going to be ignored. (Since Appium 1.18.0)

  • headers (dict) – [multipart/form-data requests] Headers mapping (Since Appium 1.18.0)

  • 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 recorded. Available formats: Execute ffmpeg -codecs in the terminal to see the list of supported video codecs. ‘mjpeg’ by default. (Since Appium 1.10.0)

  • videoFps (int) – [iOS] The Frames Per Second rate of the recorded video. Change this value if the resulting video is too slow or too fast. Defaults to 10. This can decrease the resulting file size.

  • videoFilters (str) – [iOS] The FFMPEG video filters to apply. These filters allow to scale, flip, rotate and do many other useful transformations on the source video stream. The format of the property must comply with https://ffmpeg.org/ffmpeg-filters.html. (Since Appium 1.15)

  • videoScale (str) – [iOS] The scaling value to apply. Read https://trac.ffmpeg.org/wiki/Scaling for possible values. No scale is applied by default. If videoFilters are set then the scale setting is effectively ignored. (Since Appium 1.10.0)

  • pixelFormat (str) – [iOS] Output pixel format. Run ffmpeg -pix_fmts to list possible values. For Quicktime compatibility, 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 native display resolution (if supported), 1280x720 if not. For best results, use a size supported by your device’s Advanced Video Coding (AVC) encoder.

  • bitRate (int) – [Android] The video bit rate for the video, in bits per second. The default value is 4000000 (4 Mbit/s). You can increase the bit rate to improve video quality, but doing so results in larger movie files.

  • bugReport (bool) – [Android] Makes the recorder to display an additional information on the video overlay, such as a timestamp, that is helpful in videos captured to illustrate bugs. This option is only supported since API level 27 (Android P).

  • fps (int) – [Win, macOS] The count of frames per second in the resulting video. Increasing fps value also increases the size of the resulting video file and the CPU usage.

  • captureCursor (bool) – [Win, macOS] Whether to capture the mouse cursor while recording the screen. Disabled by default.

  • captureClicks (bool) – [Win, macOS] Whether to capture the click gestures while recording the screen. Disabled by default.

  • videoFilter (str) – [Win, macOS] The FFMPEG video filter to apply. The format is the same as for videoFilters.

  • deviceId (int) – [macOS] Screen device index to use for the recording. The list of available devices could be retrieved using ffmpeg -f avfoundation -list_devices true -i command. This option is mandatory and must be always provided.

  • preset (str) – [Win, macOS] A preset is a collection of options that will provide a certain encoding speed to compression ratio. A slower preset will provide better compression (compression is quality per filesize). This means that, for example, if you target a certain file size or constant bit rate, you will achieve better quality with a slower preset. Read https://trac.ffmpeg.org/wiki/Encode/H.264 for more details. Possible values are ‘ultrafast’, ‘superfast’, ‘veryfast’(default), ‘faster’, ‘fast’, ‘medium’, ‘slow’, ‘slower’, ‘veryslow’

Usage:

driver.start_recording_screen()

Returns:

[iOS, Android] Base-64 encoded content of the recorded media

if stop_recording_screen isn’t called after previous start_recording_screen. Otherwise returns an empty string. [Win, macOS] Always None.

Return type:

str | None

stop_recording_screen(**options: Any) → str#

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

Keyword Arguments:
  • remotePath (str) – The remotePath upload option is the path to the remote location, where the resulting video should be uploaded. The following protocols are supported: http/https (multipart), ftp. Missing value (the default setting) means the content of the resulting file should be encoded as Base64 and passed as the endpoint response value, but an exception 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 authentication. Only has an effect if both remotePath and password are set.

  • password (str) – The password for the remote authentication. Only has an effect if both remotePath and user are set.

  • method (str) – The HTTP method name (‘PUT’/’POST’). PUT method is used by default. Only has an effect if remotePath is set.

  • fileFieldName (str) – [multipart/form-data requests] The name of the form field containing the binary payload. “file” by default. (Since Appium 1.18.0)

  • formFields (dict) – [multipart/form-data requests] Additional form fields mapping. If any entry has the same key as fileFieldName then it is going to be ignored. (Since Appium 1.18.0)

  • headers (dict) – [multipart/form-data requests] Headers mapping (Since Appium 1.18.0)

Usage:
payload = driver.stop_recording_screen()
with open('media.mp4', "wb") as fd:
    import base64
    fd.write(base64.b64decode(payload))
Returns:

Base-64 encoded content of the recorded media file or an empty string

if the file has been successfully uploaded to a remote location (depends on the actual remotePath value).

Return type:

str

webdriver.extensions.session module#

class Session(*args, **kwargs)#

Bases: CanExecuteCommands

property events: dict#

Retrieves events information from the current session

Usage:

events = driver.events

Returns:

containing events timing information 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 Settings for the current session.

Do not get Settings confused with Desired Capabilities, they are separate concepts. See appium/appium

Returns:

Current settings

update_settings(settings: dict[str, Any]) → Self#

Set settings for the current session.

For more on settings, see: appium/appium

Parameters:

settings – dictionary of settings to apply to the current test session

Module contents#