Skip to main content

Appium Testing - Virtual Device On HyperExecute

This page outlines how to execute your Appium tests on HyperExecute using TestNG with YAML 0.2

HyperExecute uses YAML 0.2 to perform the tests using Appium.

Prerequisites​

To run the Tests on HyperExecute from your Local System, you are required:

Sample repo

All the code samples in this documentation can be found on LambdaTest's Github Repository. You can either download or clone the repository to quickly run your tests. Image View on GitHub

If you do not have any .apk file, you can run your sample tests on LambdaTest by using our sample 🔗 Android app

Download HyperExecute CLI​

The HyperExecute CLI is used for triggering tests on HyperExecute. It is recommend to download the HyperExecute CLI binary on the host system to perform the tests on HyperExecute. The CLI download site for various platforms is displayed below:

PlatformHyperExecute CLI download location
Windowshttps://downloads.lambdatest.com/hyperexecute/windows/hyperexecute.exe
macOShttps://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute
Linuxhttps://downloads.lambdatest.com/hyperexecute/linux/hyperexecute

Setup Environment Variable​

Export the environment variables LT_USERNAME and LT_ACCESS_KEY that are available in the LambdaTest Profile page. Run the below mentioned commands in the terminal to setup the CLI and the environment variables.

export LT_USERNAME="undefined"
export LT_ACCESS_KEY="undefined"

Steps to Run Your Test​

Step 1: Upload your Application​

Upload your android application (.apk file) to the LambdaTest servers using our REST API. You need to provide your Username and AccessKey in the format Username:AccessKey in the cURL command for authentication. Make sure to add the path of the appFile in the cURL request. Here is an example cURL request to upload your app using our REST API:

curl -u "undefined:undefined" --location --request POST 'https://manual-api.lambdatest.com/app/upload/virtualDevice' --form 'name="Android_App"' --form 'appFile=@"<RELATIVE_PATH_OF_YOUR_APP>"' 

Response of above cURL will be a JSON object containing the App URL of the format - lt://APP123456789123456789 and will be used in the next step.

Step 2: Configure your Test Script​

Write Your Automation Script in the client language of your choice from the ones supported by Appium. An automation script for the sample applications have been provided below.

Here is a sample automation script in Java for the sample app downloaded above. Ensure to update the app_url, username and accesskey in the below code.

AndroidEmulator.java
loading...

Step 3: Update your XML file​

Create .XML file in order to run your test and define device capabilities. Please find sample code below for the same.

android-emulator.xml
loading...

Step 4: Configure YAML and Execute your Script​

android-emulator.yaml
loading...

Step 5: Execute your Test Suite​

NOTE : In case of MacOS, if you get a permission denied warning while executing CLI, simply run chmod u+x ./hyperexecute to allow permission. In case you get a security popup, allow it from your System Preferences → Security & Privacy → General tab.

Run the below command in your terminal at the root folder of the project:

./hyperexecute --config RELATIVE_PATH_OF_YOUR_YAML_FILE

OR use this command if you have not exported your username and access key in the step 2.

./hyperexecute --user undefined --key undefined --config RELATIVE_PATH_OF_YOUR_YAML_FILE 

Test across 3000+ combinations of browsers, real devices & OS.

Book Demo

Help and Support

Related Articles