Pre-requisites

You should have an Account in Sauce Labs.

Generate Code Snippet of Sauce Labs Capabilities

You can run the QAS test scripts using Sauce Labs capabilities of your choices. Follow the steps below to get your desired Sauce Labs capabilities.


1. Go to https://wiki.saucelabs.com/display/DOCS/Platform+Configurator

2. Configure the platform for the desired capabilities and generate the capabilities code, which will then be used in QAS to configure Sauce Labs.

The following screenshot shows generated Code Snippet of capabilities.



Set Capabilities for Sauce Labs in QAS


1. Setup a project for Android Platform. Refer to Install and Set Up Android Automation Environment.

2. Open the QMetry menu and select Test Recorder.

3. Create Test Suites and Test Cases as mentioned in Record Test Cases.

4. Select the test case for which you want to record the steps.

5. Click on the Record tab and select Android.



The next screen opens to provide the Capabilities for Sauce Labs.


Set Sauce Labs Capabilities from Code Snippet


1. Enter Sauce Username and Sauce Access Key.

2. Use the Code Snippet that you generated in the initial step above. Enter the values from that Code Snippet to QAS.






On clicking the Add Field button, the default capabilities from the Sauce Labs library are displayed on the drop-down on the capabilities section. You can define the required capabilities for the configuration.


3. Once you enter the values, save the Capability.



Code View

You can switch the field view to code view by clicking on Switch View, which is toggle one.



Once the capability is saved, it appears on the Capabilities List at right.

To record a test case for an Android application, click Start.




The recording starts.

After starting the session, the following screen appears to let you record the test case.




Start recording test cases. Refer to Record Test Cases for more details.

Once you are done with recording the test case, you can then execute the recorded step to verify the test case. 

Execute Recorded Test Case in Sauce Labs


In QAS

1. Go to QMetry > Test Recorder.

2. Select the test case that you want to execute.

3. On the right pane, select Execute > Android.



4. The capabilities screen opens.



5. On the Capabilities List, select the capabilities using which you want to execute the test case. Click Start to start the execution.


In Sauce Labs

1. Go to Sauce Labs and verify the job has started.

2. Click on the execution job the progress of which you want to view.



The execution status in QAS will be updated once the test run is completed.



Execute Test Scripts in Sauce Labs

1. Record test case and export.

  1. Go to QMetry > Test Recorder.
  2. Select the test case that you want to execute.
  3. Click on the Code tab on the right pane.
  4. Export code the code. Refer to Export Code for more details.


2. application.properties:

In resource/application.properties file, set -

platform=android


3. env.properties:

In resources/android/env.properties file, set -

appium.additional.capabilities = Set the same capabilities that have been used while recording QAS test case. Refer to Integration with Sauce Labs#Code View mentioned above.

remote.server = Mention Sauce Labs server URL as per configuration.



4. Open a new terminal from Terminal > New Terminal.



5. Execute the following command. It will trigger the execution on Sauce Labs.

mvn clean test 



You can see the execution logs like below in QAS once the test run is completed.



Test Reports

To view test reports, go to QMetry > Test Reports.

As an alternate way, you can open dashboard.htm in a browser to view the reports in a browser.