Appium integration

The integration with Appium allows you to run Appium scripts utilizing the features of Mobile Center. Note that iOS versions earlier than 9.3 are not supported.

Prepare your environment

To prepare your environment to run an automated Appium test, you need to configure your working environment such as Visual Studio or Eclipse to recognize the Appium project.

Back to top

Prepare your Appium test

To prepare your Appium test to run on Mobile Center:

  • In the code that starts the session, replace the Appium server URL and port with the URL and port of Mobile Center using the following format (see below for an example):

    driver = new AndroidDriver(new URL("http://<myMCServer>:<port>/wd/hub"), capabilities);

    driver = new IOSDriver(new URL("http://<myMCServer>:<port>/wd/hub"), capabilities);

  • Make your apps available for the test by uploading them to Mobile Center. For details, see View, upload, and manage apps.

Note: You do not need a Mac machine to install apps on an iOS device.

Back to top

Appium script execution

Mobile Center allows you to run tests on iOS devices without requiring a Mac machine.

When running your Appium tests through Mobile Center, you can indicate the method of automation to use during script execution.

iOS

The default automation method used for iOS is XCUITest.

If you explicitly want to use UIA automation, set the automationName Appium capability to uiAutomation. This capability is only available for iOS versions 9.3 through 11.1. In iOS versions higher than 11.1, the capability is not supported and all tests will use XCUITest.

Note: If you are running your Appium test through a Micro Focus testing tool, such as UFT, you can use a connector on any platform (Mac, Windows, or Linux) . If however, you want to run a pure Appium execution using XCUItest, your device must be connected via a Mac connector.

Android

The default automation execution method used for Android is UiAutomator1.

The uiautomator2 driver uses Google's UiAutomator2 technology to allow automation on a device or emulator. To use UiAutomator2, set the automationName Appium capability to uiautomator2.

Back to top

Appium setup code snippets

The following code snippets show sample setups for Android native apps, Chrome, iOS native apps, and iOS Safari. The bolded lines are mandatory.

Tip: Refer to the See Also section for links to more examples.

For a list of the common capabilities and their support in Mobile Center, see Mobile Center Appium Capabilities.

Back to top

Common Appium API calls

Use the following Appium API calls to manage your apps or add network virtualization capabilities within Mobile Center.

Tip: Refer to the See Also section for links to more examples.

Back to top

Retrieve Appium logs

A log file is generated during the execution of your Appium test.

To retrieve the log, use the mc-wd:downloadLogs script and specify the encoding.

When the connector receives this command, it retrieves the contents of the Appium log file for the current testing session, as a string. Attach the string to the response body.

The Appium user's test code uses the string from the response body and processes it accordingly.

For example:

HashMap<String, String> encoding= new HashMap<String, String>();

encoding.put("encoding", "UTF-8");

String logFileContents = (String) wd.executeScript("mc-wd: downloadLogs", encoding);

Back to top

Parallel tests

You can run parallel Appium and Selenium tests on Mobile Center.

You can do this through coding, or using your CI (Continuous Integration) tools such as Jenkins. For an example of how to run parallel tests in Jenkins, see the Jenkins Wiki.

Back to top

See also: