You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/smartui-layout-comparison.md
+71-44
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
id: smartui-layout-testing
3
3
title: Layout Comparison in SmartUI SDK
4
-
sidebar_label: Layout Testing
4
+
sidebar_label: Layout Testing (Beta)
5
5
description: Learn how to use SmartUI SDK's layout testing feature to verify only the layout structure of your pages while ignoring content and style changes
6
6
keywords:
7
7
- layout comparison
@@ -17,11 +17,66 @@ site_name: LambdaTest
17
17
slug: smartui-layout-testing/
18
18
---
19
19
20
+
21
+
Layout testing is a specialized approach to visual testing that focuses on verifying the structural integrity and arrangement of UI elements rather than their specific content or styling. It ensures that your application's visual hierarchy and element positioning remain consistent across different environments and updates.
22
+
23
+
The example below demonstrates localisation testing, one of the major use cases of layout testing, where a webpage is tested across languages and locales.
1.**Structural Consistency**: Ensures that UI elements maintain their intended positions and relationships, regardless of content changes or style updates.
30
+
31
+
2.**Cross-Environment Reliability**: Validates that your application's layout remains intact across different:
32
+
- Operating systems
33
+
- Browsers
34
+
- Devices
35
+
- Screen sizes
36
+
- Viewport dimensions
37
+
38
+
3.**Design System Compliance**: Helps maintain consistency with your design system by verifying that components follow established layout patterns.
39
+
40
+
# What Layout Comparison Ignores
41
+
42
+
When using layout comparison, the following aspects are ignored:
43
+
44
+
1.**Text Content**: Changes in text content are not considered in the comparison
45
+
2.**Color Values**: Differences in color schemes or individual color values are ignored
46
+
3.**Style Properties**: Changes in CSS properties like font size, padding, margins, etc. are not compared
47
+
4.**Image Content**: Differences in image content are ignored, only their position and size are considered
48
+
49
+
## Visual Diffs vs. Layout Diffs
50
+
51
+
52
+
Understanding the difference between content and layout is crucial for effective visual testing:
53
+
54
+
-**Visual Diffs** refer to the actual information that users interact with on a webpage, such as text, images, videos, and other elements that convey your message.
55
+
In the example below, you can see the visual differences between the baseline and comparison screenshot using Smart Ignore Diff Option.
-**Layout** pertains to the arrangement and presentation of this content, including the positioning, styling, and structuring of elements. The goal of layout design is to ensure that content is visually appealing and well-organized.
60
+
In the example below, you can see the layout differences between the baseline and comparison screenshot using Layout Diff Option.
SmartUI's layout comparison feature allows you to focus specifically on layout differences while ignoring content changes, giving you more precise control over your visual testing process.
65
+
20
66
# Layout Comparison in SmartUI SDK
21
67
22
-
The layout comparison feature in SmartUI SDK allows you to verify only the layout structure of your pages while ignoring content and style changes. This is particularly useful for frontend developers who need to ensure that the structural integrity of their UI remains consistent across different versions or environments.
68
+
> **Beta Feature Notice**: The Layout Comparison feature is currently in beta and is a work in progress based on user feedback. To use this feature, you need to get it enabled by contacting our support team at [email protected]. Using this feature without getting it enabled will not work.
69
+
70
+
71
+
## Prerequisites
72
+
73
+
Before using the Layout Comparison feature, ensure you meet the following requirements:
74
+
75
+
- SmartUI CLI version `4.1.8` or above is installed
76
+
- The feature is only supported when using the `smartui exec` (smartUISnapshot) command
@@ -54,7 +109,7 @@ import TabItem from '@theme/TabItem';
54
109
```python
55
110
# Set options to focus only on layout structure
56
111
options = {
57
-
"ignoreType": "layout"
112
+
"ignoreType": ["layout"]
58
113
}
59
114
60
115
# Take a screenshot with layout comparison enabled
@@ -64,9 +119,9 @@ import TabItem from '@theme/TabItem';
64
119
<TabItemvalue="csharp"label="C#">
65
120
```csharp
66
121
// Set options to focus only on layout structure
67
-
var options = new SmartUIOptions
122
+
var options = new Dictionary<string, object>
68
123
{
69
-
IgnoreType = "layout"
124
+
{ "ignoreType", new List<string> { "layout" } }
70
125
};
71
126
72
127
// Take a screenshot with layout comparison enabled
@@ -77,7 +132,7 @@ import TabItem from '@theme/TabItem';
77
132
```ruby
78
133
# Set options to focus only on layout structure
79
134
options = {
80
-
ignoreType: "layout"
135
+
ignoreType: ["layout"]
81
136
}
82
137
83
138
# Take a screenshot with layout comparison enabled
@@ -86,34 +141,14 @@ import TabItem from '@theme/TabItem';
86
141
</TabItem>
87
142
</Tabs>
88
143
89
-
This configuration tells SmartUI to focus only on the layout structure while comparing screenshots, ignoring content and style changes.
90
-
91
-
## What Layout Comparison Verifies
92
-
93
-
The layout comparison feature specifically focuses on:
94
-
95
-
1.**Element Positions**: The relative positioning of elements compared to their siblings
96
-
2.**Parent-Child Relationships**: The hierarchical structure of elements in the DOM
97
-
3.**Basic Structural Hierarchy**: The overall layout structure of the page
98
-
99
-
## What Layout Comparison Ignores
100
-
101
-
When using layout comparison, the following aspects are ignored:
102
-
103
-
1.**Text Content**: Changes in text content are not considered in the comparison
104
-
2.**Color Values**: Differences in color schemes or individual color values are ignored
105
-
3.**Style Properties**: Changes in CSS properties like font size, padding, margins, etc. are not compared
106
-
4.**Image Content**: Differences in image content are ignored, only their position and size are considered
144
+
## Known Limitations
107
145
108
-
## Content vs. Layout Diffs
146
+
The Layout Comparison feature has the following limitations:
109
147
110
-
Understanding the difference between content and layout is crucial for effective visual testing:
111
-
112
-
-**Content** refers to the actual information that users interact with on a webpage, such as text, images, videos, and other elements that convey your message.
113
-
114
-
-**Layout** pertains to the arrangement and presentation of this content, including the positioning, styling, and structuring of elements. The goal of layout design is to ensure that content is visually appealing and well-organized.
148
+
- Not supported with Fetch APIs
149
+
- Not supported with Slack, Email, and GitHub integrations
150
+
- Performance may vary based on the complexity of the page structure
115
151
116
-
SmartUI's layout comparison feature allows you to focus specifically on layout differences while ignoring content changes, giving you more precise control over your visual testing process.
117
152
118
153
## Use Cases for Layout Comparison
119
154
@@ -131,14 +166,6 @@ The layout comparison feature is particularly valuable in the following scenario
131
166
132
167
6.**Cross-Environment Testing**: Ensure that your page structure remains intact across different operating systems, browsers, devices, viewport sizes, and orientations.
133
168
134
-
## Validations
135
-
136
-
When using layout comparison, SmartUI performs the following validations:
137
-
138
-
1.**Layout Structure Extraction**: The system extracts the layout structure from the page
139
-
2.**Position Calculations**: Accurate calculation of element positions relative to each other
140
-
3.**Relative Positioning**: Preservation of relative positioning between elements
141
-
4.**Viewport Considerations**: Proper handling of viewport dimensions and scrolling
0 commit comments