diff --git a/assets/images/hyperexecute/release-notes/test-history-label.gif b/assets/images/hyperexecute/release-notes/test-history-label.gif new file mode 100644 index 000000000..02e269d39 Binary files /dev/null and b/assets/images/hyperexecute/release-notes/test-history-label.gif differ diff --git a/docs/hyperexecute-appium-testing.md b/docs/hyperexecute-appium-testing.md index 74b1557df..6d6120dc6 100644 --- a/docs/hyperexecute-appium-testing.md +++ b/docs/hyperexecute-appium-testing.md @@ -1,7 +1,7 @@ --- id: hyperexecute-appium-testing -title: Appium Testing On HyperExecute -sidebar_label: HyperExecute Appium Testing +title: Appium Testing - Real Device On HyperExecute +sidebar_label: Appium - Real Device description: Maximize Appium test execution with HyperExecute – Explore LambdaTest's support documentation for seamless automation testing. keywords: - appium @@ -19,6 +19,8 @@ slug: 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'; - ---- - - - This page outlines how to execute your Appium tests on HyperExecute using TestNG with YAML 0.2 - > HyperExecute uses [YAML 0.2](/support/docs/hyperexecute-yaml-version0.2/) to perform the tests using Appium. - - -## Running Appium Tests on HyperExecute -*** - -### Prerequisites +## Prerequisites To run the Tests on HyperExecute from your Local System, you are required: @@ -75,12 +59,12 @@ To run the Tests on HyperExecute from your Local System, you are required: - Ensure you have Appium’s [Java client library](https://github.com/appium/java-client) installed. - Access to an **Android** app (.apk or .aab file) or an **iOS** app (.ipa file). - - - +:::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. Image 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 :link: [Android app](https://prod-mobile-artefacts.lambdatest.com/assets/docs/proverbial_android.apk) or sample :link: [iOS app](https://prod-mobile-artefacts.lambdatest.com/assets/docs/proverbial_ios.ipa). -#### Download HyperExecute CLI +### 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: @@ -94,37 +78,35 @@ The *HyperExecute CLI* is used for triggering tests on HyperExecute. It is recom Export the environment variables *LT_USERNAME* and *LT_ACCESS_KEY* that are available in the [LambdaTest Profile page](https://accounts.lambdatest.com/detail/profile). Run the below mentioned commands in the terminal to setup the CLI and the environment variables. -*** + -For macOS: + -```bash -export LT_USERNAME=YOUR_LT_USERNAME -export LT_ACCESS_KEY=YOUR_LT_ACCESS_KEY -``` - -For Linux: +
+ + {`export LT_USERNAME="${ YOUR_LAMBDATEST_USERNAME()}" +export LT_ACCESS_KEY="${ YOUR_LAMBDATEST_ACCESS_KEY()}"`} + +
-```bash -export LT_USERNAME=YOUR_LT_USERNAME -export LT_ACCESS_KEY=YOUR_LT_ACCESS_KEY -``` +
-For Windows: + -```bash -set LT_USERNAME=YOUR_LT_USERNAME -set LT_ACCESS_KEY=YOUR_LT_ACCESS_KEY -``` - -### Steps to Run Your Test +
+ + {`set LT_USERNAME="${ YOUR_LAMBDATEST_USERNAME()}" +set LT_ACCESS_KEY="${ YOUR_LAMBDATEST_ACCESS_KEY()}"`} + +
---- +
+
-**Step 1:** 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: +## Steps to Run Your Test -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; +### 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: @@ -182,324 +164,81 @@ import TabItem from '@theme/TabItem'; > 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:** 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. - -:::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. Image View on GitHub -::: +### 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. -```java -import io.appium.java_client.AppiumDriver; -import io.appium.java_client.MobileBy; -import io.appium.java_client.MobileElement; -import io.appium.java_client.android.AndroidElement; -import org.openqa.selenium.remote.DesiredCapabilities; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; -import java.net.URL; -import java.util.List; - -public class AndroidApp { - - public static String userName = "username"; //Enter your LT Username here - public static String accessKey = "accesskey"; //Enter your LT AccessKey here - - public String gridURL = "@mobile-hub.lambdatest.com/wd/hub"; - - String DeviceValue; - String versionValue; - String PlatformValue; - - - @org.testng.annotations.Parameters(value = {"device", "version", "platform"}) - public AndroidApp(String device, String version, String platform) { - try { - DeviceValue = device; - versionValue = version; - PlatformValue = platform; - DesiredCapabilities capabilities = new DesiredCapabilities(); - capabilities.setCapability("build","ParallelSample Android"); - capabilities.setCapability("name",platform+" "+device+" "+version); - capabilities.setCapability("deviceName", device); - capabilities.setCapability("platformVersion",version); - capabilities.setCapability("platformName", platform); - capabilities.setCapability("isRealMobile", true); - //AppURL (Create from Wikipedia.apk sample in project) - capabilities.setCapability("app", "app url"); //Enter your app URL from previous step here - capabilities.setCapability("deviceOrientation", "PORTRAIT"); - capabilities.setCapability("console", true); - capabilities.setCapability("network", true); - capabilities.setCapability("visual", true); - capabilities.setCapability("devicelog", true); - - String hub = "https://" + userName + ":" + accessKey + gridURL; - AppiumDriver driver = new AppiumDriver(new URL(hub), capabilities); - - MobileElement color = (MobileElement) driver.findElementById("com.lambdatest.proverbial:id/color"); - //Changes color - color.click(); - //Back to black color - color.click(); - - MobileElement text = (MobileElement) driver.findElementById("com.lambdatest.proverbial:id/Text"); - //Changes the text to proverbial - text.click(); - - //toast is visible - MobileElement toast = (MobileElement) driver.findElementById("com.lambdatest.proverbial:id/toast"); - toast.click(); - - //notification is visible - MobileElement notification = (MobileElement) driver.findElementById("com.lambdatest.proverbial:id/notification"); - notification.click(); - - //Open the geolocation page - MobileElement geo = (MobileElement) driver.findElementById("com.lambdatest.proverbial:id/geoLocation"); - geo.click(); - Thread.sleep(5000); - - //takes back to home page - MobileElement home = (MobileElement) driver.findElementByAccessibilityId("Home"); - home.click(); - - //Takes to speed test page - MobileElement speedtest = (MobileElement) driver.findElementById("com.lambdatest.proverbial:id/speedTest"); - speedtest.click(); - Thread.sleep(5000); - MobileElement el10 = (MobileElement) driver.findElementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.view.ViewGroup/android.widget.RelativeLayout/android.widget.FrameLayout[1]/android.widget.FrameLayout/android.widget.RelativeLayout/android.webkit.WebView/android.webkit.WebView/android.view.View/android.view.View/android.view.View[1]/android.view.View[3]/android.view.View[1]/android.view.View/android.widget.Button"); - el10.click(); - Thread.sleep(25000); - - - MobileElement el11 = (MobileElement) driver.findElementByXPath("//android.widget.FrameLayout[@content-desc=\"Home\"]/android.widget.FrameLayout/android.widget.ImageView"); - el11.click(); - - //Opens the browser - MobileElement browser = (MobileElement) driver.findElementByAccessibilityId("Browser"); - browser.click(); - MobileElement el13 = (MobileElement) driver.findElementById("com.lambdatest.proverbial:id/url"); - el13.sendKeys("www.lambdatest.com"); - MobileElement el14 = (MobileElement) driver.findElementById("com.lambdatest.proverbial:id/find"); - el14.click(); - driver.quit(); - - - } catch (Exception t) { - System.out.println(); - - } - - - } -} +```java reference title="AndroidApp.java" +https://github.com/LambdaTest/hyperexecute-real-device-appium-testng/blob/main/src/main/java/AndroidApp.java ``` -```java -import io.appium.java_client.AppiumDriver; -import io.appium.java_client.MobileElement; -import org.openqa.selenium.JavascriptExecutor; -import org.openqa.selenium.remote.DesiredCapabilities; -import java.net.URL; - -public class iOSApp { - - public static String userName = "username"; //Enter your LT Username here - public static String accessKey = "accesskey"; //Enter your LT AccessKey here - - public String gridURL = "@mobile-hub.lambdatest.com/wd/hub"; - - String DeviceValue; - String versionValue; - String PlatformValue; - AppiumDriver driver; - - - @org.testng.annotations.Parameters(value = {"device", "version", "platform"}) - public iOSApp(String device, String version, String platform) { - try { - DeviceValue = device; - versionValue = version; - PlatformValue = platform; - DesiredCapabilities capabilities = new DesiredCapabilities(); - capabilities.setCapability("build","ParallelSample iOS"); - capabilities.setCapability("name",platform+" "+device+" "+version); - capabilities.setCapability("deviceName", device); - capabilities.setCapability("platformVersion",version); - capabilities.setCapability("platformName", platform); - capabilities.setCapability("isRealMobile", true); - //AppURL (Create from proverbial.ipa sample in project) - capabilities.setCapability("app", "app url"); //Enter your app URL from previous step here - capabilities.setCapability("deviceOrientation", "PORTRAIT"); - capabilities.setCapability("console", true); - capabilities.setCapability("network", true); - capabilities.setCapability("visual", true); - capabilities.setCapability("devicelog", true); - //capabilities.setCapability("geoLocation", "HK"); - - String hub = "https://" + userName + ":" + accessKey + gridURL; - driver = new AppiumDriver(new URL(hub), capabilities); - - MobileElement color = (MobileElement) driver.findElementByAccessibilityId("Colour"); - //Changes color - color.click(); - //Back to black color - color.click(); - - MobileElement text = (MobileElement) driver.findElementByAccessibilityId("Text"); - //Changes the text to proverbial - text.click(); - - //toast is visible - MobileElement toast = (MobileElement) driver.findElementByAccessibilityId("Toast"); - toast.click(); - - //notification is visible - MobileElement notification = (MobileElement) driver.findElementByAccessibilityId("Notification"); - notification.click(); - - //Open the geolocation page - MobileElement geo = (MobileElement) driver.findElementByAccessibilityId("GeoLocation"); - geo.click(); - Thread.sleep(5000); - - //Takes back - driver.navigate().back(); - - //Takes to speed test page - MobileElement speedtest = (MobileElement) driver.findElementByAccessibilityId("Speed Test"); - speedtest.click(); - Thread.sleep(5000); - MobileElement el10 = (MobileElement) driver.findElementByAccessibilityId("start speed test - connection type multi"); - el10.click(); - Thread.sleep(25000); - - driver.navigate().back(); - - //Opens the browser - MobileElement browser = (MobileElement) driver.findElementByAccessibilityId("Browser"); - browser.click(); - Thread.sleep(3000); - - MobileElement el4 = (MobileElement) driver.findElementByAccessibilityId("Search"); - el4.click(); - el4.sendKeys("Lambdatest"); - - ((JavascriptExecutor) driver).executeScript("lambda-status=passed"); - driver.quit(); - - - } catch (Exception t) { - System.out.println(); - ((JavascriptExecutor) driver).executeScript("lambda-status=failed"); - driver.quit(); - - } - - - } -} +```java reference title="iOSApp.java" +https://github.com/LambdaTest/hyperexecute-real-device-appium-testng/blob/main/src/main/java/iOSApp.java ``` -**Step 3:** Create `.XML` file in order to run your test and define device capabilities. Please find sample code below for the same. +### 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 - - - - - - - - - - - - - - - - - - - - - - - + +```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 +``` + + -```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 +``` -**Step 4:** Execute Your Test Case. Debug and run your code. Run `iOSApp.java` or `AndroidApp.java` in your editor. +> 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) -Once you have run your tests, you can view the test execution along with logs. You will be able to see the test cases passing or failing. You can view the same at [LambdaTest Automation](https://accounts.lambdatest.com/login). +### 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**. -## Sample YAML 0.2 +Run the below command in your terminal at the root folder of the project: ```bash -version: 0.2 -runson: android -concurrency: 1 -dynamicAllocation: true -testDiscovery: - type: raw - mode: static - command: grep -r -l --include="*.xml" ".*" src/test/java/ | sed 's#.*/##' | sed 's/\.xml$//' -testRunnerCommand: mvn test -P $test -framework: - name: appium - args: - region: us +./hyperexecute --config RELATIVE_PATH_OF_YOUR_YAML_FILE ``` -> 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) + +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 @@ -514,41 +253,38 @@ To configure SmartUI with HyperExecute, you need to simply add a capability in y automation-dashboard ## More About Desired Capabilities - ---- - Sample Capabilities for both android and iOS are mentioned below - ```java { - "deviceName": "Galaxy Tab S4", - "platformName": "android", - "platformVersion": "10", - "app": "App_url", - "visual": True, - "console": True, - "deviceOrientation": "PORTRAIT", - "build": "new-12", - "isRealMobile": True, + "deviceName": "Galaxy Tab S4", + "platformName": "android", + "platformVersion": "10", + "app": "App_url", + "visual": True, + "console": True, + "deviceOrientation": "PORTRAIT", + "build": "new-12", + "isRealMobile": True, } ``` -``` +```java { - "deviceName": "iPhone 12 Mini", - "platformName": "ios", - "platformVersion": "14", - "app": "App_url", - "isRealMobile": True, - "visual": True, - "console": True, - "build": "lt-web-4", - "network": True, + "deviceName": "iPhone 12 Mini", + "platformName": "ios", + "platformVersion": "14", + "app": "App_url", + "isRealMobile": True, + "visual": True, + "console": True, + "build": "lt-web-4", + "network": True, } ``` @@ -565,10 +301,6 @@ The snapshot below shows how to navigate to the respective *testID* for viewing automation-dashboard -## Conclusion -By following the instructions in this documentation, you can seamlessly execute the Appium tests on HyperExecute, leveraging its secure cloud infrastructure, advanced features, and optimized test execution workflow. - -