*** Analysis of capabilities parameters

Posted by kaeRock on Mon, 07 Mar 2022 17:52:25 +0100

1. Sample script

from appium import webdriver

# After starting appium service, execute on appium service: start snowball app with caps parameter
driver = webdriver.Remote(command_executor="http://localhost:4723/wd/hub", # command_executor source code is the default local 4723 interface. If we run appium locally, it can be deleted in principle
                              "platformName": "android",  # Running on Android platform
                              "deviceName": "008640dd0804",  # Run on 008xxx mobile device
                              "automationName": "uiautomator2",  # Automation plug-ins used at the bottom
                              "appPackage": "com.xueqiu.android",  # Which app is running
                              "appActivity": ".view.WelcomeActivityAlias",  #
                              "autoGrantPermissions": "true"  # app is allowed to obtain relevant permissions by default

# Click an element
el1 = driver.find_element_by_id("com.xueqiu.android:id/tv_agree")

# Add invisible wait

# Click an element
el2 = driver.find_element_by_xpath(

# Send text
el3 = driver.find_element_by_id("com.xueqiu.android:id/search_input_text")

# Exit app

2,desired_ Analysis of capabilities parameters

2.1 global parameters:

  1. Platform name: which platform do you want to run on? You can set it to android
  2. automationName: must always be set to uiautomator2
  3. deviceName: the name of the device under test
  1. noReset: resets the device cleaning data. It is reset by default
  2. fullReset: full reset will uninstall the app under test. By default, it is not fully reset
  3. printPageSourceOnFindFailure: if an error is reported, dump the actual XML page source to the log
  4. Platform version: used for automatic device detection
  5. UDID: the UDID of the device to be tested. It can be retrieved from adb devices -l output. If not set, the driver will attempt to use the first connected device. If you run parallel tests, always set this feature.

2.2 driver and server parameters:

  1. Skippserverinstallation: skip the installation of UiAutomator2 server components and all related checks on the tested device. The default is false
  2. disableWindowAnimation: detect whether to disable window animation when starting the process. The default is false
  3. skipDeviceInitialization: set to true to cancel the device startup check during session creation, which can speed up session creation. The default is false
  1. systemPort: the port number on which the UiAutomator2 server is listening. By default, the first free port in the range of 8200... 8299 is selected. This value is recommended if you are running parallel tests on the same machine.
  2. uiautomator2ServerLaunchTimeout: the maximum number of milliseconds that UiAutomator2Server listens on the device. 30000 defaults to milliseconds
  3. uiautomator2ServerInstallTimeout: the maximum number of milliseconds to wait for UiAutomator2Server to be installed on the device. 20000 defaults to milliseconds
  4. Uiautomator2serverredtimeout: the maximum number of milliseconds to wait for an HTTP response from UiAutomator2Server.

2.3 App parameters:

  1. appActivity: the name of the main application activity
  2. appPackage: identifier of the application package
  3. autoLaunch: whether to automatically start the application under test after the test starts. The default is True
  4. autoGrantPermissions: automatically grant all requested application permissions at the beginning of the test. The default is False
  5. otherApps: set one or more comma separated Android package paths, which will be installed with the tested main application. If the application being tested has dependencies
  6. Uninstall other packages: allows you to set one or more comma separated package identifiers to uninstall from the device before the test starts
  7. enforceAppInstall: true, the application under test will always be reinstalled, even if a newer version of the application already exists on the device under test
  1. app: the full path of the application to be tested
  2. browserName: the name of the browser that ran the test
  3. appWaitActivity: wait for activity name
  4. appWaitPackage: wait for the package
  5. appWaitDuration: the maximum number of milliseconds to wait for the application under test to start
  6. Android installtimeout: the maximum number of milliseconds waiting to install the application under test
  7. appWaitForLaunch: whether to block until the application under test returns control to the caller after its activity is started by the activity manager (true, default), or continue the test without waiting (false).
  8. intentCategory: sets the optional intention category applied when starting a given appActivity through the Activity Manager
  9. intentAction: sets the optional intention action to be applied when starting a given appActivity through the Activity Manager
  10. intentFlags: sets the optional intention flag applied when starting a given appActivity through the Activity Manager
  11. Optional intent arguments: sets the optional intent parameters applied when the given appActivity is started by the Activity Manager
  12. dontStopAppOnReset: the application was restarted at runtime
  13. Allow test packages: packages built with the test flag are used for automated testing
  14. remoteAppsCacheLimit: sets the maximum number of application packages to be cached on the device under test

2.4 App localization parameters:

  1. Localscript: the specification name of the locale set for the application under test, such as zh Hans CN
  2. Language: the name of the language for which you want to extract the application string. The default is to extract the string for the current system language.
  3. Locale: set the locale of the application under test

Topics: Appium