Skip to content

Commit 1664d96

Browse files
JeeveshJ7JeeveshJ7
JeeveshJ7
authored and
JeeveshJ7
committed
Layout Doc Sanity
1 parent f44e00e commit 1664d96

File tree

4 files changed

+71
-44
lines changed

4 files changed

+71
-44
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.

docs/smartui-layout-comparison.md

+71-44
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
id: smartui-layout-testing
33
title: Layout Comparison in SmartUI SDK
4-
sidebar_label: Layout Testing
4+
sidebar_label: Layout Testing (Beta)
55
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
66
keywords:
77
- layout comparison
@@ -17,11 +17,66 @@ site_name: LambdaTest
1717
slug: smartui-layout-testing/
1818
---
1919

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.
24+
25+
<img loading="lazy" src={require('../assets/images/smart-visual-testing/layout/localisation-netflix.webp').default} alt="cmd" width="768" height="373" className="doc_img"/>
26+
27+
### Why Layout Testing Matters
28+
29+
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.
56+
57+
<img loading="lazy" src={require('../assets/images/smart-visual-testing/layout/smartignore-amazon.webp').default} alt="cmd" width="768" height="373" className="doc_img"/>
58+
59+
- **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.
61+
62+
<img loading="lazy" src={require('../assets/images/smart-visual-testing/layout/layout-amazon.webp').default} alt="cmd" width="768" height="373" className="doc_img"/>
63+
64+
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+
2066
# Layout Comparison in SmartUI SDK
2167

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
77+
- The feature must be enabled by contacting [email protected]
2378

24-
## How to Use Layout Comparison
79+
## How to Use Layout Comparison with SmartUI
2580

2681
To use the layout comparison feature, you need to set the `ignoreType` option to `"layout"` when taking a screenshot:
2782

@@ -33,8 +88,8 @@ import TabItem from '@theme/TabItem';
3388
```javascript
3489
// Set options to focus only on layout structure
3590
let options = {
36-
ignoreType: "layout"
37-
};
91+
ignoreType: ["layout"]
92+
}
3893

3994
// Take a screenshot with layout comparison enabled
4095
await smartuiSnapshot(driver, "ScreenshotName", options);
@@ -43,8 +98,8 @@ import TabItem from '@theme/TabItem';
4398
<TabItem value="java" label="Java">
4499
```java
45100
// Set options to focus only on layout structure
46-
SmartUIOptions options = new SmartUIOptions();
47-
options.IgnoreType("layout");
101+
Map<String, Object> options = new HashMap<>();
102+
options.put("ignoreType", Arrays.asList("layout"));
48103

49104
// Take a screenshot with layout comparison enabled
50105
smartuiSnapshot(driver, "ScreenshotName", options);
@@ -54,7 +109,7 @@ import TabItem from '@theme/TabItem';
54109
```python
55110
# Set options to focus only on layout structure
56111
options = {
57-
"ignoreType": "layout"
112+
"ignoreType": ["layout"]
58113
}
59114

60115
# Take a screenshot with layout comparison enabled
@@ -64,9 +119,9 @@ import TabItem from '@theme/TabItem';
64119
<TabItem value="csharp" label="C#">
65120
```csharp
66121
// Set options to focus only on layout structure
67-
var options = new SmartUIOptions
122+
var options = new Dictionary<string, object>
68123
{
69-
IgnoreType = "layout"
124+
{ "ignoreType", new List<string> { "layout" } }
70125
};
71126

72127
// Take a screenshot with layout comparison enabled
@@ -77,7 +132,7 @@ import TabItem from '@theme/TabItem';
77132
```ruby
78133
# Set options to focus only on layout structure
79134
options = {
80-
ignoreType: "layout"
135+
ignoreType: ["layout"]
81136
}
82137

83138
# Take a screenshot with layout comparison enabled
@@ -86,34 +141,14 @@ import TabItem from '@theme/TabItem';
86141
</TabItem>
87142
</Tabs>
88143

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
107145

108-
## Content vs. Layout Diffs
146+
The Layout Comparison feature has the following limitations:
109147

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
115151

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.
117152

118153
## Use Cases for Layout Comparison
119154

@@ -131,14 +166,6 @@ The layout comparison feature is particularly valuable in the following scenario
131166

132167
6. **Cross-Environment Testing**: Ensure that your page structure remains intact across different operating systems, browsers, devices, viewport sizes, and orientations.
133168

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
142169

143170
## Example Implementation
144171

0 commit comments

Comments
 (0)