Running Appium tests

The following sections describe how to run Appium tests in some of the common frameworks.

Running Tips

Before running your Appium test for Digital Lab, make sure your environment is set up properly and that you have included the required capabilities. For details, see Appium integration.

Consider the following when running Appium tests:

  • When forcibly stopping an Appium test (for example while debugging code), the device remains locked on the Digital Lab server, only becoming available after several minutes.
  • The kill application extension is not supported in .NET environments.
  • After an Appium test starts to run and the device is locked, you can open the device remotely from Digital Lab and view the test running live:
    • Before opening the device remotely, refresh the list of devices and check that the device is locked.
    • Only the user whose username-password or key are used in the script can open the device. You can not open a device remotely during an Appium test when anonymous access is enabled and a username-password or key are not specified in the script.

Refer to the See also section for links to sample code.

Back to top

Run your Appium test in Eclipse

To run your Appium test in Eclipse:

  1. Open your project in Eclipse. Set the Digital Lab Appium Capabilities as needed, including the server and device information.
  2. Launch the test.
  3. View the Eclipse console and ensure that your test is running properly.
  4. View the actions on the device through the Digital Lab console. The device becomes locked and reserved by you.

Back to top

Run your Appium test with Apache Ant

To run your Appium test with Ant:

  1. Download and install Apache Ant.
  2. Set the required environment variables.
  3. Open a command dialog box and navigate to your Appium workspace path.
  4. Run the command ant <test_name>.java. Your test run begins.
  5. View the Ant console and ensure that your test is running.
  6. View the actions on the device through the Digital Lab console. The device becomes locked and reserved by you.

Back to top

Run a single job project in Jenkins

To run your Appium test as a Jenkins job: (Terminology refers to Jenkins 2.00 and higher):

  1. Download and install Apache Ant. Set the relevant environment variables.
  2. Open the Jenkins dashboard and click New item.
  3. Specify an Item name and click Freestyle project.
  4. In the General tab, click Advanced.
  5. Select Use custom workspace and enter your Appium workspace path.
  6. In the Build section, select Invoke ant.
  7. Click the Advanced button. Provide a target name and the full path to the build.xml file in the Build File field.
  8. Click Save.
  9. On the project page, click Build Now.
  10. View the actions on the device through the Digital Lab console. The device becomes locked and reserved by you.
  11. Inside the Build History list, click on the build number. In the pane that opens, click Console Output to view the test execution log in the Jenkins console.

Back to top

Run a MultiJob project in Jenkins

To run multiple Appium tests as a Jenkins job: (Terminology refers to Jenkins 2.00 and higher):

  1. Prepare several single job freestyle jobs, as described above.
  2. Click New item and specify a MultiJob project. Click OK.
  3. In the Build section, select MultiJob Phase from the Add build step drop-down. Enter a phase name.
  4. Click Add jobs and select the first job you want to add. Repeat this step for all the jobs you want to include in this phase.
  5. Select an option from the Job execution type drop-down: sequentially or in parallel. If you are executing multiple jobs, but only have one device, the jobs are executed sequentially—not in parallel.

  6. Optionally, select a continuation condition, for example: Always, Successful, or Completed.
  7. Click Save.
  8. On the project page, click Build Now.
  9. View the actions on the device(s) through the Digital Lab console. The devices become locked and reserved by you.
  10. Inside the Build History list, click on the build number. In the pane that opens, click Console Output to view the test execution log in the Jenkins console.
  11. You can download all the Appium logs using the REST API call GET /rest/logs/serverLogs?filter=appium. For details, see the REST API reference for Digital Lab.

Tip: The udid, name, and platformVersion capabilities are optional. You can use the platformName capability alone, to instruct the Appium test to look for the next available device.

Back to top

See also: