Skip to content

Commit 87e4235

Browse files
authored
Merge pull request LambdaTest#1826 from RushilK7/stage
User Docs update for SmartUI - MaestroSample, CustomRequestHeaders, RCA
2 parents c2bd239 + f07c63a commit 87e4235

File tree

11 files changed

+469
-49883
lines changed

11 files changed

+469
-49883
lines changed
11 KB
Loading
11.3 KB
Loading
10.6 KB
Loading
15.6 KB
Loading
60.5 KB
Loading
14.8 KB
Loading
Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
---
2+
id: hyperexecute-smart-ui-sdk-maestro
3+
title: UI Testing with Maestro using HyperExecute and SmartUI SDK
4+
hide_title: false
5+
sidebar_label: Maestro
6+
description: Use the Maestro framework to run visual tests on Android apps via HyperExecute and SmartUI. Capture screenshots for visual comparison in mobile test automation.
7+
keywords:
8+
- smartui mobile testing
9+
- hyperexecute android tests
10+
- maestro visual regression
11+
- appium alternative
12+
- visual testing android emulator
13+
- smartui app screenshots
14+
- hyperexecute yaml mobile
15+
url: https://www.lambdatest.com/support/docs/hyperexecute-smart-ui-sdk-maestro/
16+
site_name: LambdaTest
17+
slug: hyperexecute-smart-ui-sdk-maestro/
18+
---
19+
20+
import CodeBlock from '@theme/CodeBlock';
21+
import { YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY } from "@site/src/component/keys";
22+
import Tabs from '@theme/Tabs';
23+
import TabItem from '@theme/TabItem';
24+
25+
<script type="application/ld+json"
26+
dangerouslySetInnerHTML={{ __html: JSON.stringify({
27+
"@context": "https://schema.org",
28+
"@type": "BreadcrumbList",
29+
"itemListElement": [{
30+
"@type": "ListItem",
31+
"position": 1,
32+
"name": "LambdaTest",
33+
"item": "https://www.lambdatest.com"
34+
},{
35+
"@type": "ListItem",
36+
"position": 2,
37+
"name": "Support",
38+
"item": "https://www.lambdatest.com/support/docs/"
39+
},{
40+
"@type": "ListItem",
41+
"position": 3,
42+
"name": "UI Testing with Maestro",
43+
"item": "https://www.lambdatest.com/support/docs/hyperexecute-smart-ui-maestro/"
44+
}]
45+
})
46+
}}
47+
></script>
48+
49+
This document guides you on how to perform visual regression testing for your Android applications by running your Maestro tests on the HyperExecute platform and capturing screenshots with the SmartUI SDK.
50+
51+
## Prerequisites
52+
53+
Before you begin, ensure you have the following prerequisites in place:
54+
55+
* Your LambdaTest Username and Access Key. You can find these on your dashboard -> left side bar -> credentials.
56+
* The [HyperExecute CLI](/support/docs/hyperexecute-cli-run-tests-on-hyperexecute-grid/) downloaded to your local machine.
57+
* An existing Android application file (`.apk`).
58+
* Node.js and npm installed on your system.
59+
60+
## Step 1: Create a SmartUI Project
61+
62+
First, you need to create a project in SmartUI. All your visual regression test builds for this project will be grouped here.
63+
64+
1. Navigate to the [SmartUI Projects page](https://smartui.lambdatest.com/).
65+
2. Click on **New Project**.
66+
3. Select **CLI** as the platform.
67+
4. Provide a **Project Name**, select approvers, and add any relevant tags.
68+
5. Click **Submit**.
69+
70+
:::info
71+
Once the project is created, you will get a unique `PROJECT_TOKEN`. Copy this token as it is required in the HyperExecute YAML configuration file later.
72+
:::
73+
74+
## Step 2: Clone The Sample Repository
75+
76+
You can configure your own existing Maestro project or get started quickly by cloning our sample repository.
77+
78+
```bash
79+
git clone https://github.com/LambdaTest/smartui-maestro-sample
80+
cd smartui-maestro-sample
81+
```
82+
83+
:::tip Sample Repo
84+
You can find the complete code for this example in the following LambdaTest GitHub repository.
85+
86+
<a href="https://github.com/LambdaTest/smartui-maestro-sample" className="github__anchor"><img loading="lazy" src={require('../assets/images/icons/github.png').default} alt="Image" className="doc_img"/> View on GitHub</a>
87+
88+
:::
89+
90+
## Step 3: Upload Your Application
91+
92+
To run your tests on LambdaTest real devices or emulators, you need to upload your Android app (`.apk`) and get an `appId`.
93+
94+
Run the following `cURL` command in your terminal. Ensure you have set your `LT_USERNAME` and `LT_ACCESS_KEY` as environment variables.
95+
96+
97+
<div className="lambdatest__codeblock">
98+
<CodeBlock className="language-bash">
99+
{`curl -u "${ YOUR_LAMBDATEST_USERNAME()}:${ YOUR_LAMBDATEST_ACCESS_KEY()}" -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" -F "appFile=@"<YOUR_LOCAL_APP_PATH>"" -F "name="sampleApp""
100+
`}
101+
</CodeBlock>
102+
</div>
103+
104+
From the JSON response, copy the value of `app_url`. It will be in the format `lt://...`. This is your `appId`.
105+
106+
## Step 4: Configure Your Test Suite
107+
108+
Now, let's set up the test suite to integrate with SmartUI.
109+
110+
#### 4.1. Install SmartUI CLI
111+
112+
The SmartUI CLI is required to capture and upload screenshots. Install it in your project directory:
113+
114+
```bash
115+
npm i @lambdatest/smartui-cli
116+
```
117+
118+
#### 4.2. Add SmartUI Screenshots to Your Maestro Flow
119+
120+
In your Maestro test YAML files (e.g., `maestro-test/test.yaml`), add the `takeScreenshot` command wherever you want to capture a visual checkpoint. The `path` specified will be used to name the screenshot in the SmartUI dashboard.
121+
122+
```yaml
123+
- launchApp
124+
- takeScreenshot:
125+
path: ./screenshots/home-screen
126+
- tapOn: "Login"
127+
- takeScreenshot:
128+
path: ./screenshots/login-page
129+
```
130+
131+
#### 4.3. Set Up Environment Variables
132+
133+
Now, you need to export your environment variables *LT_USERNAME* and *LT_ACCESS_KEY* that are available in the [LambdaTest Username and Access Key Page](https://accounts.lambdatest.com/security/username-accesskey).
134+
135+
Run the below mentioned commands in your terminal to setup the CLI and the environment variables.
136+
137+
<Tabs className="docs__val">
138+
<TabItem value="bash" label="Linux / MacOS" default>
139+
140+
<div className="lambdatest__codeblock">
141+
<CodeBlock className="language-bash">
142+
{`export LT_USERNAME="${ YOUR_LAMBDATEST_USERNAME()}"
143+
export LT_ACCESS_KEY="${ YOUR_LAMBDATEST_ACCESS_KEY()}"`}
144+
</CodeBlock>
145+
</div>
146+
147+
</TabItem>
148+
149+
<TabItem value="powershell" label="Windows" default>
150+
151+
<div className="lambdatest__codeblock">
152+
<CodeBlock className="language-powershell">
153+
{`set LT_USERNAME="${ YOUR_LAMBDATEST_USERNAME()}"
154+
set LT_ACCESS_KEY="${ YOUR_LAMBDATEST_ACCESS_KEY()}"`}
155+
</CodeBlock>
156+
</div>
157+
158+
</TabItem>
159+
</Tabs>
160+
161+
162+
## Step 5: Configure the HyperExecute YAML
163+
164+
The HyperExecute YAML file is the blueprint for your test execution. It tells HyperExecute how to set up the environment and run your tests.
165+
166+
You need to add your `PROJECT_TOKEN` (from Step 1) and your `appId` (from Step 3) to the YAML file. Below are example configurations for running Maestro tests on Emulators and Real Devices.
167+
168+
<Tabs className="docs__val">
169+
<TabItem value="android-rd" label="Android-Real Device" default>
170+
171+
```yaml reference title="maestro_Real_Devices.yaml"
172+
https://github.com/LambdaTest/smartui-maestro-sample/blob/main/yaml/maestro_Real_Devices.yaml
173+
```
174+
</TabItem>
175+
176+
<TabItem value="android-emu" label="Android-Emulator" default>
177+
178+
> To enable this for your organizaton, connect with us through our <span className="doc\_\_lt" onClick={() => window.openLTChatWidget()}>**24/7 chat support**</span> or drop us an email to [[email protected]](mailto:[email protected]).
179+
180+
```yaml reference title="maestro_Emulator_HyperEx.yaml"
181+
https://github.com/LambdaTest/smartui-maestro-sample/blob/main/yaml/maestro_Emulator_HyperEx.yaml
182+
```
183+
</TabItem>
184+
185+
</Tabs>
186+
187+
188+
:::info
189+
In the real device configuration, the `testDiscovery` and `testRunnerCommand` are handled internally by the `maestro` framework integration on HyperExecute. You just need to specify the `framework` block.
190+
:::
191+
192+
## Step 6: Execute Your Test Suite
193+
194+
Run the below command in your terminal at the root folder of the project:
195+
196+
```bash
197+
./hyperexecute --config RELATIVE_PATH_OF_YOUR_YAML_FILE
198+
```
199+
200+
OR use this command if you have not exported your username and access key in the step 2.
201+
202+
<div className="lambdatest__codeblock">
203+
<CodeBlock className="language-bash">
204+
{`./hyperexecute --user ${ YOUR_LAMBDATEST_USERNAME()} --key ${ YOUR_LAMBDATEST_ACCESS_KEY()} --config RELATIVE_PATH_OF_YOUR_YAML_FILE `}
205+
</CodeBlock>
206+
</div>
207+
208+
<img loading="lazy" src={require('../assets/images/hyperexecute/frameworks/maestro/1.png').default} alt="JUnit HyperExecute Terminal Logs" width="1920" height="868" className="doc_img"/>
209+
210+
211+
## Step 7: View Your Visual Test Results on SmartUI
212+
213+
After the HyperExecute job is finished, all screenshots captured using the `takeScreenshot` command will be available in your SmartUI project for review.
214+
215+
<img loading="lazy" src={require('../assets/images/smart-visual-testing/smartui-sdk-results-primer.webp').default} alt="SmartUI Results" width="768" height="373" className="doc_img"/>
216+
217+
1. Navigate to the [SmartUI Dashboard](https://smartui.lambdatest.com/).
218+
2. Select your project and the most recent build.
219+
3. Here, you can compare screenshots against the baseline, highlight differences, and approve or reject changes. You can use features like Smart Ignore to mask dynamic areas for more stable comparisons.
220+
221+
222+
<nav aria-label="breadcrumbs">
223+
<ul className="breadcrumbs">
224+
<li className="breadcrumbs__item">
225+
<a className="breadcrumbs__link" target="_self" href="https://www.lambdatest.com">
226+
Home
227+
</a>
228+
</li>
229+
<li className="breadcrumbs__item">
230+
<a className="breadcrumbs__link" target="_self" href="https://www.lambdatest.com/support/docs/">
231+
Support
232+
</a>
233+
</li>
234+
<li className="breadcrumbs__item breadcrumbs__item--active">
235+
<span className="breadcrumbs__link">SmartUI App SDK</span>
236+
</li>
237+
</ul>
238+
</nav>
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
id: smartui-cli-request-headers
3+
title: Adding Custom Request Headers in SmartUI CLI
4+
hide_title: false
5+
sidebar_label: Custom Request Headers
6+
description: Learn how to configure the SmartUI CLI to send custom HTTP headers for fetching protected assets during visual regression testing.
7+
keywords:
8+
- smartui cli
9+
- custom request headers
10+
- http headers
11+
- visual testing configuration
12+
- smartui.json
13+
- protected assets
14+
url: https://www.lambdatest.com/support/docs/smartui-cli-request-headers/
15+
site_name: LambdaTest
16+
slug: smartui-cli-request-headers/
17+
---
18+
19+
import CodeBlock from '@theme/CodeBlock';
20+
21+
<script type="application/ld+json"
22+
dangerouslySetInnerHTML={{ __html: JSON.stringify({
23+
"@context": "https://schema.org",
24+
"@type": "BreadcrumbList",
25+
"itemListElement": [{
26+
"@type": "ListItem",
27+
"position": 1,
28+
"name": "LambdaTest",
29+
"item": "https://www.lambdatest.com"
30+
},{
31+
"@type": "ListItem",
32+
"position": 2,
33+
"name": "Support",
34+
"item": "https://www.lambdatest.com/support/docs/"
35+
},{
36+
"@type": "ListItem",
37+
"position": 3,
38+
"name": "Custom Request Headers in SmartUI CLI",
39+
"item": "https://www.lambdatest.com/support/docs/smartui-cli-request-headers/"
40+
}]
41+
})
42+
}}
43+
></script>
44+
45+
The SmartUI CLI includes a `requestHeaders` configuration option, allowing you to specify custom HTTP headers for fetching web assets during your visual testing workflow. This feature is essential for scenarios where resources like images, CSS, or scripts are located behind a protected environment that requires authentication via custom headers (e.g., a staging environment).
46+
47+
By including these headers in the SmartUI CLI configuration, you can seamlessly access protected resources, enhancing the flexibility and security of your automated visual testing process.
48+
49+
## Configuration in `smartui.json`
50+
51+
To use this feature, you need to add the `requestHeaders` array to your `smartui.json` configuration file. This array contains objects, where each object represents a key-value pair for a custom header. The CLI will automatically include these headers in all HTTP requests it makes to fetch assets for rendering the webpage.
52+
53+
### Example Configuration
54+
55+
Below is an example of how to configure custom headers in your `smartui.json` file.
56+
57+
```json title="smartui.json"
58+
{
59+
"smartUI": {
60+
"project": "Your Project Name",
61+
"build": "Build Name"
62+
},
63+
"requestHeaders": [
64+
{
65+
"X-Custom-Header-1": "custom-value-1"
66+
},
67+
{
68+
"Authorization": "Bearer your-access-token"
69+
},
70+
{
71+
"X-Custom-Header-2": "custom-value-2"
72+
}
73+
]
74+
}
75+
````
76+
77+
### Explanation
78+
79+
* **`requestHeaders`**: An array of objects.
80+
* **Header Object**: Each object in the array defines a single HTTP header.
81+
* **Key**: The name of the HTTP header (e.g., `Authorization`, `X-Custom-Header-1`).
82+
* **Value**: The corresponding value for the header (e.g., `Bearer your-access-token`, `custom-value-1`).
83+
84+
### Steps to Implement
85+
86+
1. **Locate Your Configuration File**: Open your `smartui.json` file, which should be in the root directory of your project.
87+
2. **Add the `requestHeaders` Array**: If the array does not already exist, add it to the JSON structure.
88+
3. **Define Your Headers**: Inside the `requestHeaders` array, add a new object for each header you need to send. Each object must contain a single key-value pair representing the header's name and its value.
89+
4. **Save the File**: Once you save the changes, the SmartUI CLI will use this configuration for the next test run.
90+
91+
:::note
92+
93+
* You can define multiple headers by adding more objects to the `requestHeaders` array.
94+
* The headers defined in this configuration will be sent with every page load and asset request made by the SmartUI CLI during the test.
95+
* This feature is particularly useful for testing web applications in staging or development environments that are protected from public access.
96+
:::

0 commit comments

Comments
 (0)