Skip to content

Files

Latest commit

 

History

History
322 lines (257 loc) · 12.7 KB

hyperexecute-appium-testing.md

File metadata and controls

322 lines (257 loc) · 12.7 KB
id title sidebar_label description keywords image url site_name slug
hyperexecute-appium-testing
Appium Testing - Real Device On HyperExecute
Appium - Real Device
Maximize Appium test execution with HyperExecute – Explore LambdaTest's support documentation for seamless automation testing.
appium
java
lambdatest java
framework on lambdatest
testng
app testing
real devices
/assets/images/og-images/appium-testing-og-image.jpg
LambdaTest
hyperexecute-appium-testing/

import CodeBlock from '@theme/CodeBlock'; import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/component/keys"; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify({ "@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [{ "@type": "ListItem", "position": 1, "name": "Home", "item": "https://www.lambdatest.com" },{ "@type": "ListItem", "position": 2, "name": "Support", "item": "https://www.lambdatest.com/support/docs/" },{ "@type": "ListItem", "position": 3, "name": "Getting Started With Appium Testing on LambdaTest", "item": "https://www.lambdatest.com/support/docs/hyperexecute-appium-testing/" }] }) }} ></script>

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:

:::tip 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. <img loading="lazy" src={require('../assets/images/icons/github.png').default} alt="Image" className="doc_img"/> View on GitHub :::

If you do not have any .apk or .ipa file, you can run your sample tests on LambdaTest by using our sample 🔗 Android app or sample 🔗 iOS 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:

Platform HyperExecute CLI download location
Windows https://downloads.lambdatest.com/hyperexecute/windows/hyperexecute.exe
macOS https://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute
Linux https://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="${ YOUR_LAMBDATEST_USERNAME()}" export LT_ACCESS_KEY="${ YOUR_LAMBDATEST_ACCESS_KEY()}"`}
{`set LT_USERNAME="${ YOUR_LAMBDATEST_USERNAME()}" set LT_ACCESS_KEY="${ YOUR_LAMBDATEST_ACCESS_KEY()}"`}

Steps to Run Your Test

Step 1: Upload your Application

Upload your iOS application (.ipa file) or 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 "${ YOUR_LAMBDATEST_USERNAME()}:${ YOUR_LAMBDATEST_ACCESS_KEY()}" --location --request POST 'https://manual-api.lambdatest.com/app/upload/realDevice' --form 'name="Android_App"' --form 'appFile=@""' `}
{`curl -u "${ YOUR_LAMBDATEST_USERNAME()}:${ YOUR_LAMBDATEST_ACCESS_KEY()}" -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" -F "appFile=@""" `}
{`curl -u "${ YOUR_LAMBDATEST_USERNAME()}:${ YOUR_LAMBDATEST_ACCESS_KEY()}" \\ --location --request POST 'https://manual-api.lambdatest.com/app/upload/realDevice' \\ --form 'name="Android_App"' \\ --form 'url="https://prod-mobile-artefacts.lambdatest.com/assets/docs/proverbial_android.apk"'`}
{`curl -u "${ YOUR_LAMBDATEST_USERNAME()}:${ YOUR_LAMBDATEST_ACCESS_KEY()}" --location --request POST "https://manual-api.lambdatest.com/app/upload/realDevice" --header "Content-Type: application/x-www-form-urlencoded" --data-urlencode "url=:https://prod-mobile-artefacts.lambdatest.com/assets/docs/proverbial_android.apk" --data-urlencode "name=Proverbial_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.

https://github.com/LambdaTest/hyperexecute-real-device-appium-testng/blob/main/src/main/java/AndroidApp.java
https://github.com/LambdaTest/hyperexecute-real-device-appium-testng/blob/main/src/main/java/iOSApp.java

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.

```xml reference title="android-parallel.xml" https://github.com/LambdaTest/hyperexecute-real-device-appium-testng/blob/main/src/test/java/android-parallel.xml ``` ```xml reference title="ios-parallel.xml" https://github.com/LambdaTest/hyperexecute-real-device-appium-testng/blob/main/src/test/java/ios-parallel.xml ```

Step 4: Configure YAML and Execute your Script

```yaml reference title="android-parallel.yaml" https://github.com/LambdaTest/hyperexecute-real-device-appium-testng/blob/main/yaml/android/hyp-rd-android-multiple.yaml ``` ```yaml reference title="ios-parallel.yaml" https://github.com/LambdaTest/hyperexecute-real-device-appium-testng/blob/main/yaml/ios/hyp-rd-ios-multiple.yaml ```

The region parameter specifies the region or location where the Appium tests will be executed. Our platform supports the following three regions:

  • ap (Asia-Pacific)
  • us (United States)
  • eu (European Union)

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 PreferencesSecurity & PrivacyGeneral 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 ${ YOUR_LAMBDATEST_USERNAME()} --key ${ YOUR_LAMBDATEST_ACCESS_KEY()} --config RELATIVE_PATH_OF_YOUR_YAML_FILE `}

Configure Smart UI

To configure SmartUI with HyperExecute, you need to simply add a capability in your test file:

"smartUI.project": "<YOUR_SMARTUI_PROJECT_NAME>"

Refer to the Automation Capabilities Generator to understand how to write the capability in different languages.

<img loading="lazy" src={require('../assets/images/hyperexecute/frameworks/appium/capability-generator.png').default} alt="automation-dashboard" width="1920" height="868" className="doc_img"/>

More About Desired Capabilities

Sample Capabilities for both android and iOS are mentioned below -

{
  "deviceName": "Galaxy Tab S4",
  "platformName": "android",
  "platformVersion": "10",
  "app": "App_url",
  "visual": True,
  "console": True,
  "deviceOrientation": "PORTRAIT",
  "build": "new-12",
  "isRealMobile": True,
}
{
  "deviceName": "iPhone 12 Mini",
  "platformName": "ios",
  "platformVersion": "14",
  "app": "App_url",
  "isRealMobile": True,
  "visual": True,
  "console": True,
  "build": "lt-web-4",
  "network": True,
}

For more details, please refer to our guide on Desired Capabilities in Appium.

Navigation in Automation Dashboard

Every test run on the HyperExecute has a unique jobId associated with it. Each jobId can in turn constitute single (or multiple) groupId(s). You can visit HyperExecute automation dashboard for checking the status of the test execution.

The snapshot below shows how to navigate to the respective testID for viewing the Selenium logs:

<img loading="lazy" src={require('../assets/images/hyperexecute/frameworks/appium/hyperexecute-appium.png').default} alt="automation-dashboard" width="1920" height="868" className="doc_img"/>