Run Appium scripts remotely

This topic describes how to set up your Appium environment and run tests remotely in the SRF environment lab.

Prepare your Appium environment

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

Back to top

Prepare your Appium test

Do the following to prepare your Appium test to run remotely in SRF:

  1. In the code the starts the session, replace the Appium server URL and port with the SRF URL and port.

    Use the following syntax:

    driver = new AndroidDriver(new URL("" + "/wd/hub"), capabilities);
    driver = new IOSDriver(new URL("" + "/wd/hub"), capabilities);
  2. In the code that starts the session, add your SRF client ID and secret as capability code.

    capabilities.SetCapability("SRF_CLIENT_ID", "<placeholder>");
    capabilities.SetCapability("SRF_CLIENT_SECRET", "<placeholder>");

    For more details, see Manage tunnels and Capability reference.

  3. Make your apps available for the test by uploading them to SRF.

    For details, see the Mobile Lab User Guide.

  4. Modify your code for deprecated elements and methods

    Beginning with version 1.6.3, Appium deprecated the following items: element for findElement. Make sure to modify your code accordingly.
    scrollTo and scrollToExact methods.

    Instead, use a driver. execute command, for example,
    driver.execute('mobile: scroll', {element: el, toVisible: true})

  5. Continue with Run your test.

For more details about additional supported capabilities and samples, see:

Back to top

Run your test

Run your test using the relevant steps for your testing tool:

As your test runs, the device is locked and reserved by you in the SRF mobile lab.

The running tests icon in the upper right corner of SRF indicates that your test is running.

Back to top

Retrieve Appium logs

A log file is generated while your Appium test runs.

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

See also: