AppiumByAppiumBy.ACCESSIBILITY_IDAppiumBy.ANDROID_DATA_MATCHERAppiumBy.ANDROID_UIAUTOMATORAppiumBy.ANDROID_VIEWTAGAppiumBy.ANDROID_VIEW_MATCHERAppiumBy.CUSTOMAppiumBy.FLUTTER_INTEGRATION_KEYAppiumBy.FLUTTER_INTEGRATION_SEMANTICS_LABELAppiumBy.FLUTTER_INTEGRATION_TEXTAppiumBy.FLUTTER_INTEGRATION_TEXT_CONTAININGAppiumBy.FLUTTER_INTEGRATION_TYPEAppiumBy.IMAGEAppiumBy.IOS_CLASS_CHAINAppiumBy.IOS_PREDICATEBases: RemoteConnection
A subclass of selenium.webdriver.remote.remote_connection.Remoteconnection.
The changes are
The default user agent
the same request multiple times in the Appium server side. * https://github.com/appium/appium-base-driver/pull/400
Override get_remote_connection_headers in RemoteConnection to control the extra headers. This method will be used in sending a request method in this class.
Bases: object
Check if the service is listening on the given/default host/port.
The fact, that the service is running, does not always mean it is listening. The default host/port/base path values can be customized by providing –address/–port/–base-path command line arguments while starting the service.
True if the service is running and listening on the given/default host/port
Check if the service is running.
True if the service is running
Starts Appium service with given arguments.
If you use the service to start Appium 1.x then consider providing [’–base-path’, ‘/wd/hub’] arguments. By default, the service assumes Appium server listens on ‘/’ path, which is the default path for Appium 2.
The service will be forcefully restarted if it is already running.
env (dict) – Environment variables mapping. The default system environment, which is inherited from the parent process, is assigned by default.
node (str) – The full path to the main NodeJS executable. The service will try to retrieve it automatically if not provided.
npm (str) – The full path to the Node Package Manager (npm) script. The service will try to retrieve it automatically if not provided.
stdout (int) – Check the documentation for subprocess.Popen for more details. The default value is subprocess.DEVNULL on Windows and subprocess.PIPE on other platforms.
stderr (int) – Check the documentation for subprocess.Popen for more details. The default value is subprocess.DEVNULL on Windows and subprocess.PIPE on other platforms.
timeout_ms (int) – The maximum time to wait until Appium process starts listening for HTTP connections. If set to zero or a negative number then no wait will be applied. 60000 ms by default.
main_script (str) – The full path to the main Appium executable (usually located at build/lib/main.js). If not set then the service tries to detect the path automatically.
args (str) – List of Appium arguments (all must be strings). Check https://appium.io/docs/en/writing-running-appium/server-args/ for more details about possible arguments and their values.
of the instance (stdout/stderr must not be set to None in such case) in order to retrieve the actual process output.
Stops Appium service if it is running.
The call will be ignored if the service is not running or has been already stopped.
timeout – The maximum time in float seconds to wait for the server process to terminate
True if the service was running before being stopped
Bases: RuntimeError
Bases: RuntimeError
Check if the service is running
url – Full server url
timeout – Timeout in float seconds
custom_validator – Custom callable method to be executed upon each validation loop before the timeout happens
True if Appium server is running before the timeout
Bases: ClientConfig
ClientConfig class for Appium Python client. This class inherits selenium.webdriver.remote.client_config.ClientConfig.
//github.com/appium/python-client?tab=readme-ov-file#direct-connect-urls) is enabled.
Return if [directConnect](https
https://code.google.com/p/selenium/source/browse/spec-draft.md?repo=mobile#120
Value (Alias) |
Data |
Wifi |
Airplane Mode |
|---|---|---|---|
0 (None) |
0 |
0 |
0 |
1 (Airplane Mode) |
0 |
0 |
1 |
2 (Wifi only) |
0 |
1 |
0 |
4 (Data only) |
1 |
0 |
0 |
6 (All network on) |
1 |
1 |
0 |
Bases: object
Bases: object
Used to define an extension command as driver’s methods.
Example
When you want to add example_command which calls a get request to session/$sessionId/path/to/your/custom/url.
class YourCustomCommand(ExtensionBase):
def method_name(self):
return 'custom_method_name'
# Define a method with the name of `method_name`
def custom_method_name(self):
# Generally the response of Appium follows `{ 'value': { data } }`
# format.
return self.execute()['value']
# Used to register the command pair as "Appium command" in this driver.
def add_command(self):
return ('GET', 'session/$sessionId/path/to/your/custom/url')
# Appium capabilities
options = AppiumOptions()
driver = webdriver.Remote('http://localhost:4723/wd/hub', options=options,
extensions=[YourCustomCommand])
# Then, the driver calls a get request against
# `session/$sessionId/path/to/your/custom/url`. `$sessionId` will be
# replaced properly in the driver. Then, the method returns
# the `value` part of the response.
driver.custom_method_name()
# New commands are added by `setattr`. They remain in the module,
# so you should explicitly delete them to define the same name method
# with different arguments or process in the method.
driver.delete_extensions()
You can give arbitrary arguments for the command like the below.
class YourCustomCommand(ExtensionBase):
def method_name(self):
return 'custom_method_name'
def test_command(self, argument):
return self.execute(argument)['value']
def add_command(self):
return ('post', 'session/$sessionId/path/to/your/custom/url')
driver = webdriver.Remote('http://localhost:4723/wd/hub', options=options,
extensions=[YourCustomCommand])
# Then, the driver sends a post request to `session/$sessionId/path/to/your/custom/url`
# with `{'dummy_arg': 'as a value'}` JSON body.
driver.custom_method_name({'dummy_arg': 'as a value'})
When you customize the URL dynamically with element id.
class CustomURLCommand(ExtensionBase):
def method_name(self):
return 'custom_method_name'
def custom_method_name(self, element_id):
return self.execute({'id': element_id})['value']
def add_command(self):
return ('GET', 'session/$sessionId/path/to/your/custom/$id/url')
driver = webdriver.Remote('http://localhost:4723/wd/hub', options=options,
extensions=[YourCustomCommand])
element = driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='id')
# Then, the driver calls a get request to `session/$sessionId/path/to/your/custom/$id/url`
# with replacing the `$id` with the given `element.id`
driver.custom_method_name(element.id)
Expected to define the pair of HTTP method and its URL.
Expected to return a method name. This name will be available as a driver method.
‘str’ The method name.
Bases: WebDriver, ActionHelpers, Activities, Applications, Clipboard, Context, Common, DeviceTime, Display, ExecuteDriver, ExecuteMobileCommand, Gsm, HardwareActions, ImagesComparison, Keyboard, Location, LogEvent, Logs, Network, Performance, Power, RemoteFS, ScreenRecord, Session, Settings, Sms, SystemBars
Verifies if the given extension is not present in the list of absent extensions for the given driver instance. This API is designed for private usage.
ext_name – extension name
self instance for chaining
UnknownMethodException – If the extension has been marked as absent once
Creates a web element with the specified element_id.
Overrides method in Selenium WebDriver in order to always give them Appium WebElement
element_id – The element id to create a web element
MobileWebElement
Delete extensions added in the class with ‘setattr’
Get the Appium server status
driver.get_status()
The status information
dict
Marks the given extension as absent for the given driver instance. This API is designed for private usage.
ext_name – extension name
self instance for chaining
Gets the current orientation of the device
Example
orientation = driver.orientation
Creates a new session with the desired capabilities.
Override for Appium
capabilities – Read https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/caps.md for more details.
browser_profile – Browser profile
Returns an object containing all options to switch focus into
Override for appium
appium.webdriver.switch_to.MobileSwitchTo
Bases: WebElement
Clears text.
Override for Appium
appium.webdriver.webelement.WebElement
Gets the given attribute or property of the element.
Override for Appium
This method will first try to return the value of a property with the
given name. If a property with that name doesn’t exist, it returns the
value of the attribute with the same name. If there’s no attribute with
that name, None is returned.
Values which are considered truthy, that is equals “true” or “false”,
are returned as booleans. All other non-None values are returned
as strings. For attributes or properties which do not exist, None
is returned.
name – Name of the attribute/property to retrieve.
# Check if the “active” CSS class is applied to an element.
is_active = “active” in target_element.get_attribute(“class”)
The given attribute or property of the element
Whether the element is visible to a user.
Override for Appium
Gets the location of an element relative to the view.
The location of an element relative to the view
dict
Simulates typing into the element.
value – A string for typing.
appium.webdriver.webelement.WebElement
Appium Python Client: WebDriver module