Skip to content

Commit 3b46af7

Browse files
authored
Merge pull request #1411 from amanchopra1905/smartui-xcui-updates
xcui smartui
2 parents 1fb4e6c + d922246 commit 3b46af7

File tree

2 files changed

+221
-1
lines changed

2 files changed

+221
-1
lines changed

docs/xcui-visual-regression.md

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
---
2+
id: xcui-visual-regression
3+
title: Getting Started With Visual Regression Testing Using XCUI On SmartUI Real Devices
4+
sidebar_label: XCUI
5+
description: Dive into our detailed XCUI Visual Regression support documentation for step-by-step guidance! Efficiently perform visual testing, manage applications, and ensure your mobile apps are visually perfect before launch.
6+
keywords:
7+
- Visual Regression
8+
- Visual Regression Testing Guide
9+
- Visual Regression Test Automation
10+
- Visual Regression Automation Testing
11+
- Running Visual Regression Tests
12+
- Visual Regression Testing Online
13+
- Run Visual Regression
14+
- Visual Regression Run Specific Test
15+
- Visual Regression Testing Environment
16+
- How to Run Visual Regression Tests
17+
18+
url: https://www.lambdatest.com/support/docs/xcui-visual-regression/
19+
site_name: LambdaTest
20+
slug: xcui-visual-regression/
21+
---
22+
23+
import Tabs from '@theme/Tabs';
24+
import TabItem from '@theme/TabItem';
25+
import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/component/keys";
26+
import CodeBlock from '@theme/CodeBlock';
27+
import NewTag from '../src/component/newTag';
28+
29+
<script type="application/ld+json"
30+
dangerouslySetInnerHTML={{ __html: JSON.stringify({
31+
"@context": "https://schema.org",
32+
"@type": "BreadcrumbList",
33+
"itemListElement": [{
34+
"@type": "ListItem",
35+
"position": 1,
36+
"name": "Home",
37+
"item": "https://www.lambdatest.com"
38+
},{
39+
"@type": "ListItem",
40+
"position": 2,
41+
"name": "Support",
42+
"item": "https://www.lambdatest.com/support/docs/"
43+
},{
44+
"@type": "ListItem",
45+
"position": 3,
46+
"name": "SmartUI-Hooks",
47+
"item": "https://www.lambdatest.com/support/docs/xcui-visual-regression/"
48+
}]
49+
})
50+
}}
51+
></script>
52+
53+
XCUI (XCTest UI) is Apple's native UI testing framework used for testing iOS applications. It is part of the XCTest framework and allows developers to write UI automation tests for iOS apps. In this documentation, you will learn step-by-step how to perform regression testing and find Visual UI Regression bugs easily with the help of Smart Testing.
54+
55+
## Prerequisites
56+
57+
- Your LambdaTest [Username and Access key](https://accounts.lambdatest.com/security).
58+
- Access to an **iOS** app (.ipa) and an **iOS Test** app (.ipa file).
59+
- Go to [`LambdaTest SmartUI`](https://smartui.lambdatest.com/) and login along with your credentials.
60+
61+
## Step 1: Create a SmartUI Project
62+
63+
The first step is to create a project with the application in which we will combine all your **builds** run on the project.
64+
To create a SmartUI Project, follow these steps:
65+
66+
1. Go to [Projects page](https://smartui.lambdatest.com/)
67+
2. Click on the `new project` button
68+
3. Select the platform as <b>Real Device </b> for executing your `XCUI` tests.
69+
4. Add name of the project, approvers for the changes found, tags for any filter or easy navigation.
70+
5. Click on the **Submit**.
71+
72+
## Step 2: Set up your Authentication
73+
74+
Now, you need to export your environment variables LT_USERNAME and LT_ACCESS_KEY that are available in the [LambdaTest Profile page](https://accounts.lambdatest.com/details/profile).
75+
76+
Run the below mentioned commands in your terminal to setup the CLI and the environment variables.
77+
78+
<Tabs className="docs__val">
79+
80+
<TabItem value="bash" label="Linux / MacOS" default>
81+
<div className="lambdatest__codeblock">
82+
<CodeBlock className="language-bash">
83+
{`export LT_USERNAME=${ YOUR_LAMBDATEST_USERNAME()} \\
84+
export LT_ACCESS_KEY=${ YOUR_LAMBDATEST_ACCESS_KEY()}`}
85+
</CodeBlock>
86+
</div>
87+
88+
</TabItem>
89+
90+
<TabItem value="powershell" label="Windows" default>
91+
92+
<div className="lambdatest__codeblock">
93+
<CodeBlock className="language-powershell">
94+
{`set LT_USERNAME=${ YOUR_LAMBDATEST_USERNAME()} \`
95+
set LT_ACCESS_KEY=${ YOUR_LAMBDATEST_ACCESS_KEY()}`}
96+
</CodeBlock>
97+
</div>
98+
99+
</TabItem>
100+
</Tabs>
101+
102+
## Step 3: Upload your Application
103+
104+
To begin testing, upload your iOS application (.ipa file) to LambdaTest's servers. You'll use our **REST API** for this process.
105+
106+
- **Authentication :** You'll need your LambdaTest Username and AccessKey. Combine them in the format `Username:AccessKey`.
107+
- **Uploading the App :** Use **cURL command** to send a request to our API. The request should include the path to your application file (**appFile**).
108+
109+
<Tabs className="docs__val">
110+
111+
<TabItem value="bash" label="Linux / MacOS" default>
112+
113+
<div className="lambdatest__codeblock">
114+
<CodeBlock className="language-bash">
115+
{`curl -u "${ YOUR_LAMBDATEST_USERNAME()}:${ YOUR_LAMBDATEST_ACCESS_KEY()}" --location --request POST 'https://manual-api.lambdatest.com/app/uploadFramework' --form 'appFile=@"<PATH_OF_YOUR_IOS_APP>"' --form 'type="xcuit-ios"'`}
116+
</CodeBlock>
117+
</div>
118+
119+
</TabItem>
120+
121+
<TabItem value="powershell" label="Windows" default>
122+
123+
<div className="lambdatest__codeblock">
124+
<CodeBlock className="language-powershell">
125+
{`curl -u "${ YOUR_LAMBDATEST_USERNAME()}:${ YOUR_LAMBDATEST_ACCESS_KEY()}" --location --request POST "https://manual-api.lambdatest.com/app/uploadFramework" --form "appFile=@"<PATH_OF_YOUR_IOS_APP>"" --form "type=\"xcuit-ios\""`}
126+
</CodeBlock>
127+
</div>
128+
129+
</TabItem>
130+
</Tabs>
131+
132+
:::info
133+
- Provide the path of your ios application in the above URL in place of `<PATH_OF_YOUR_IOS_APP>`
134+
- Response of above cURL will be a **JSON** object containing the `App URL` of the format - `lt://APP123456789123456789` and will be used in the last step.
135+
:::
136+
137+
## Step 4: Upload Your Test Suite
138+
139+
Upload your XCUI test suite (.ipa) file to LambdaTest servers using our REST API.
140+
141+
The following sample cURL command shows how to upload a test suite:
142+
143+
<Tabs className="docs__val">
144+
145+
<TabItem value="bash" label="Linux / MacOS" default>
146+
147+
<div className="lambdatest__codeblock">
148+
<CodeBlock className="language-bash">
149+
{`curl -u "${ YOUR_LAMBDATEST_USERNAME()}:${ YOUR_LAMBDATEST_ACCESS_KEY()}" --location --request POST 'https://manual-api.lambdatest.com/app/uploadFramework' --form 'appFile=@"<PATH_OF_YOUR_TEST_SUITE_APP>"' --form 'type="xcuit-ios"'`}
150+
</CodeBlock>
151+
</div>
152+
153+
</TabItem>
154+
155+
<TabItem value="powershell" label="Windows" default>
156+
157+
<div className="lambdatest__codeblock">
158+
<CodeBlock className="language-powershell">
159+
{`curl -u "${ YOUR_LAMBDATEST_USERNAME()}:${ YOUR_LAMBDATEST_ACCESS_KEY()}" --location --request POST "https://manual-api.lambdatest.com/app/uploadFramework" --form "appFile=@"<PATH_OF_YOUR_TEST_SUITE_APP>"" --form "type=\"xcuit-ios\""`}
160+
</CodeBlock>
161+
</div>
162+
163+
</TabItem>
164+
</Tabs>
165+
166+
:::info
167+
- Provide the path of your ios application in the above URL in place of `<PATH_OF_YOUR_TEST_SUITE_APP>`
168+
- Response of above cURL will be a **JSON** object containing the `App URL` of the format - `lt://APP123456789123456789` and will be used in the last step.
169+
:::
170+
171+
## Step 5: Executing The Test
172+
173+
- You will need **base64 encoded authentication** in order to execute your Espresso automation test suite. Enter your `username:accesskey` in **[Basic Authentication Header Generator](https://mixedanalytics.com/knowledge-base/api-connector-encode-credentials-to-base-64/)** to generate your auth token.
174+
175+
Take note of the base64 encoded authentication which needs to be added in the next step.
176+
177+
<div className="lambdatest__codeblock">
178+
<CodeBlock className="language-powershell">
179+
{`${ YOUR_LAMBDATEST_USERNAME()}:${ YOUR_LAMBDATEST_ACCESS_KEY()}`}
180+
</CodeBlock>
181+
</div>
182+
183+
- Once you have uploaded your app and test suite, you can execute your test by running the following command:
184+
185+
> Enter your **BASIC_AUTH_TOKEN**, **APP_ID** (generated in the fourth step) and **TEST_SUITE_ID** (generated in the fifth step) in the below command.
186+
187+
```javascript
188+
curl --location 'https://mobile-api.lambdatest.com/framework/v1/xcui/build' \
189+
--header 'Authorization: Basic BASIC_AUTH_TOKEN' \
190+
--header 'Content-Type: application/json' \
191+
--data '{
192+
"app" : "APP_ID", //enter your app-id
193+
"testSuite": "TEST_SUITE_ID", //enter your test-suite id
194+
"device" : ["iPhone 13-16"], //enter your device names
195+
"smartUI.project": "XCUI-SmartUI-Project",
196+
"build" : "Proverbial-XCUITest",
197+
"video" : true,
198+
"queueTimeout": 10800,
199+
"idleTimeout": 150,
200+
"devicelog": true,
201+
"network": false,
202+
"only-testing" : ["LambdaUiKitIOSUITestsLaunchTests"],
203+
"smartUI.cropStatusBar" : true,
204+
"smartUI.cropNavigationBar" : true
205+
}'
206+
```
207+
208+
> You can check the executed builds over at [LambdaTest SmartUI](https://smartui.lambdatest.com/).
209+
210+
## Smart Crop With SmartUI
211+
212+
The all-new **Real Device mobile notification status bar and navigation bar crop** feature in SmartUI allows you to take your visual regression testing workflows to the next level. With Smart Crop, you can crop the status bar and navigation bar or footer from screenshots, enabling them to focus solely on the core UI elements during visual comparisons.
213+
214+
By leveraging machine learning algorithms, it accurately detects and crops the status bar and navigation bar from screenshots. With precise image processing techniques, SmartUI precisely identifies the location of status bar elements. By excluding it from visual comparisons, the focus is solely on critical UI elements.
215+
216+
| Original Screenshot | Cropped Screenshot |
217+
|---------------------|--------------------|
218+
| <img loading="lazy" src={require('../assets/images/smart-visual-testing/screenshot.webp').default} alt="Profile" width="1360" height="603" className="doc_img"/> | <img loading="lazy" src={require('../assets/images/smart-visual-testing/cropped_ss.jpg').default} alt="Profile" width="1360" height="603" className="doc_img"/> |

sidebars.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2848,8 +2848,10 @@ module.exports = {
28482848
label: "Visually Test Your Native Apps",
28492849
items: [
28502850
"appium-visual-regression",
2851+
"smartui-xcui-updates",
2852+
"espresso-visual-regression",
2853+
"xcui-visual-regression",
28512854
"smartui-app-sdk",
2852-
"espresso-visual-regression"
28532855
]
28542856
},
28552857
]

0 commit comments

Comments
 (0)