Skip to content

Commit 54b5683

Browse files
authored
Merge 3b8fb78 into a7d3f00
2 parents a7d3f00 + 3b8fb78 commit 54b5683

File tree

10 files changed

+162
-21
lines changed

10 files changed

+162
-21
lines changed

docs/visual-testing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ Sauce Visual provides integrations with different kind of frameworks:
161161
<li><a href="/visual-testing/integrations/java/">Java Integration</a></li>
162162
<li><a href="/visual-testing/integrations/nightwatch/">Nightwatch Integration</a></li>
163163
<li><a href="/visual-testing/integrations/webdriverio/">WebdriverIO Integration</a></li>
164+
<li><a href="/visual-testing/integrations/python/">Python Integration</a></li>
164165
</ul>
165166
</div>
166167
</div>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:::note Important
2+
Access to this feature is currently limited to Enterprise customers as part of our commitment to providing tailored solutions. We are excited to announce that self-service access is under development and will be released shortly. Stay tuned!
3+
:::

docs/visual-testing/integrations/csharp.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
sidebar_label: C#/.Net
33
---
44

5-
import useBaseUrl from '@docusaurus/useBaseUrl';
65
import Tabs from '@theme/Tabs';
76
import TabItem from '@theme/TabItem';
7+
import EnterpriseNote from '../_partials/_enterprise-note.md';
88

99
# C#/.Net WebDriver Integration
1010

11-
:::note Important
12-
Access to this feature is currently limited to Enterprise customers as part of our commitment to providing tailored solutions. We are excited to announce that self-service access is under development and will be released shortly. Stay tuned!
13-
:::
11+
<EnterpriseNote />
1412

1513
## Introduction
1614

docs/visual-testing/integrations/cypress.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ sidebar_label: Cypress
55
import Tabs from '@theme/Tabs';
66
import TabItem from '@theme/TabItem';
77
import ClippingDescription from '../_partials/_clipping-description.md';
8+
import EnterpriseNote from '../_partials/_enterprise-note.md';
89

910
# Cypress Integration
1011

11-
:::note Important
12-
Access to this feature is currently limited to Enterprise customers as part of our commitment to providing tailored solutions. We are excited to announce that self-service access is under development and will be released shortly. Stay tuned!
13-
:::
12+
<EnterpriseNote />
1413

1514
## Introduction
1615

docs/visual-testing/integrations/java.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ import Tabs from '@theme/Tabs';
66
import TabItem from '@theme/TabItem';
77
import ClippingDescription from '../_partials/_clipping-description.md';
88
import FullPageDescription from '../_partials/_fullpage-description.md';
9+
import EnterpriseNote from '../_partials/_enterprise-note.md';
910

1011
# Java WebDriver Integration
1112

12-
:::note Important
13-
Access to this feature is currently limited to Enterprise customers as part of our commitment to providing tailored solutions. We are excited to announce that self-service access is under development and will be released shortly. Stay tuned!
14-
:::
13+
<EnterpriseNote />
1514

1615
## Introduction
1716

docs/visual-testing/integrations/nightwatch.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ import Tabs from '@theme/Tabs';
66
import TabItem from '@theme/TabItem';
77
import FullPageJS from '../_partials/_fullpage-js.md'
88
import ClippingWDIO from '../_partials/_clipping-webdriver.md';
9+
import EnterpriseNote from '../_partials/_enterprise-note.md';
910

1011
# Nightwatch Integration
1112

12-
:::note Important
13-
Access to this feature is currently limited to Enterprise customers as part of our commitment to providing tailored solutions. We are excited to announce that self-service access is under development and will be released shortly. Stay tuned!
14-
:::
13+
<EnterpriseNote />
1514

1615
## Introduction
1716

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
---
2+
sidebar_label: Python
3+
---
4+
5+
import EnterpriseNote from '../_partials/_enterprise-note.md'
6+
7+
# Python Integration
8+
9+
<EnterpriseNote />
10+
11+
## Introduction
12+
13+
This document assumes an existing Python 3+ project. Alternatively, you can take a look to our [example repository](#examples) for quick-start projects.
14+
15+
Sauce Visual plugin for Python provides an interface for interacting with Sauce Labs Visual and a running Selenium session on Sauce.
16+
17+
A generic `SauceLabsVisual` client is exposed by the package to allow interaction with any Python based tooling. We also offer some additional [framework-specific options](#frameworks) which we'll expand support for over time.
18+
19+
## Installation
20+
21+
- Install the Sauce Labs Visual python package in your project, and optionally append it to your dependencies.
22+
23+
```sh
24+
pip install saucelabs_visual
25+
```
26+
27+
## Frameworks
28+
29+
### Robot Framework
30+
31+
This integration relies on the [SeleniumLibrary](https://github.com/robotframework/SeleniumLibrary) package provided by Robot Framework for automatic detection of the current session. View our [Robot Framework example on GitHub](https://github.com/saucelabs/visual-examples/tree/main/python/robot-framework/) for a fully-functional example for reference.
32+
33+
- Step 1: Add the Sauce Visual package
34+
35+
```sh
36+
pip install saucelabs_visual
37+
```
38+
39+
- Step 2: Create top-level (in a parent folder that includes no test cases) setup and teardowns with the `Create Visual Build` and `Finish Visual Build` keywords, respectively. All of your tests should be nested in directories under this to allow it to act like a global setup / teardown.
40+
41+
`<parent_dir>/__init__.robot`
42+
43+
```robot
44+
*** Settings ***
45+
# This can also be imported in a robot.resource file and referenced here instead if you prefer.
46+
# See our example repo for more details.
47+
Library saucelabs_visual.frameworks.robot.SauceLabsVisual
48+
49+
# Supply a name to recognize your build in the Sauce Labs Visual dashboard
50+
Suite Setup Create Visual Build name=Sauce Labs Visual -- Robot Framework
51+
Suite Teardown Finish Visual Build
52+
```
53+
54+
- Step 3: Add visual tests in your test / suite files using the `Visual Snapshot` keyword followed by the name for your snapshot
55+
56+
```robot
57+
*** Settings ***
58+
# We recommend putting this in your resource.robot file instead, but have omitted that here to keep the example short.
59+
Library saucelabs_visual.frameworks.robot.SauceLabsVisual
60+
61+
Invalid Login
62+
# ... Opening a selenium session, and your other assertions
63+
Visual Snapshot My Snapshot Name
64+
# ...
65+
```
66+
67+
- Step 4: Configure your Sauce Labs credentials
68+
69+
Sauce Visual relies on environment variables for authentications.<br />
70+
Both `SAUCE_USERNAME` and `SAUCE_ACCESS_KEY` need to be set prior starting your Cypress job.
71+
72+
Username and Access Key can be retrieved from https://app.saucelabs.com/user-settings.
73+
74+
```sh
75+
export SAUCE_USERNAME=__YOUR_SAUCE_USER_NAME__
76+
export SAUCE_ACCESS_KEY=__YOUR_SAUCE_ACCESS_KEY__
77+
```
78+
79+
- Step 5: Run the tests
80+
81+
Upon executing your tests for the first time under this step, a visual baseline is automatically created in our system. This baseline serves as the standard for all subsequent tests. As new tests are run, they are compared to this original baseline, with any deviations highlighted to signal visual changes. These comparisons are integral for detecting any unintended visual modifications early in your development cycle. All test builds, including the initial baseline and subsequent runs, can be monitored and managed through the Sauce Labs platform at [Sauce Visual Builds](https://app.saucelabs.com/visual/builds).
82+
83+
Remember, the baseline is established during the initial run, and any subsequent visual differences detected will be marked for review.
84+
85+
### Generic / Framework Agnostic
86+
87+
:::info
88+
If you're looking for support with additional frameworks, you can submit a feature request on our [Productboard](https://portal.productboard.com/sauceprod/2-sauce-labs-portal/tabs/4-under-consideration/submit-idea) to help us prioritize which SDKs we roll out first.
89+
:::
90+
91+
:::note
92+
This client currently requires that you're running an existing WDIO session on Sauce and can access the session ID for interaction with our Visual API.
93+
:::
94+
95+
For more technical users, we also expose a generic SauceLabsVisual client which can be used to interact with the Visual API for a running Selenium / WDIO session on Sauce in case your framework is not officially supported yet.
96+
97+
Generally, the workflow would be as follows:
98+
99+
- Import and instantiate the client, and keep the instance somewhere globally, so you can access it.
100+
101+
```python
102+
from saucelabs_visual.client import SauceLabsVisual
103+
104+
client = SauceLabsVisual()
105+
```
106+
107+
- Either manually or in a `beforeAll` hook that is only triggered once in your framework, create the Visual build that we'll associate all screenshots with.
108+
109+
```python
110+
# Creates a build and stores the build meta in the client instance for processing & interaction later
111+
client.create_build(
112+
name='My Python Build',
113+
# Any other named parameters that are available. See the source / docs for more information on
114+
# options for customizing your build.
115+
# project="my-project",
116+
# branch="my-ci-branch",
117+
)
118+
```
119+
120+
- Take a visual snapshot in each test where you'd like to check for visual changes
121+
122+
We recommend creating a helper class / function within your framework of choice to reduce the duplication / need to pass the test metadata (such as test / suite name) into each call.
123+
124+
```python
125+
session_id = 'YOUR_SESSION_ID' # Get your Selenium session ID from your framework
126+
client.create_snapshot_from_webdriver(
127+
name="Snapshot Name",
128+
session_id=session_id,
129+
# Other optional items to customize your snapshots / associate them with the current test run
130+
# test_name="TEST_NAME_FROM_YOUR_FRAMEWORK",
131+
# suite_name="SUITE_NAME_FROM_YOUR_FRAMEWORK",
132+
)
133+
```
134+
135+
136+
- Either manually or in an `afterAll` hook that is only triggered once at the end of your framework, finish the Visual build to let Sauce Visual know we're ready to present the results in the UI.
137+
138+
```python
139+
# Finish the currently opened build associated with this instance
140+
client.finish_build()
141+
```
142+
143+
## Examples
144+
145+
Example projects are available [here](https://github.com/saucelabs/visual-examples/tree/main/python).

docs/visual-testing/integrations/storybook.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@ sidebar_label: Storybook
33
---
44

55
import useBaseUrl from '@docusaurus/useBaseUrl';
6-
import Tabs from '@theme/Tabs';
7-
import TabItem from '@theme/TabItem';
6+
import EnterpriseNote from '../_partials/_enterprise-note.md';
87

98
# Storybook Integration
109

11-
:::note Important
12-
Access to this feature is currently limited to Enterprise customers as part of our commitment to providing tailored solutions. We are excited to announce that self-service access is under development and will be released shortly. Stay tuned!
13-
:::
10+
<EnterpriseNote />
1411

1512
An extension for [Storybook's test-runner](https://github.com/storybookjs/test-runner) powered by [Jest](https://jestjs.io/) and [Playwright](https://playwright.dev/) to integrate effortless visual testing with Sauce Visual.
1613

docs/visual-testing/integrations/webdriverio.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ sidebar_label: WebdriverIO
44

55
import FullPageJS from '../_partials/_fullpage-js.md';
66
import ClippingWDIO from '../_partials/_clipping-webdriver.md';
7+
import EnterpriseNote from '../_partials/_enterprise-note.md';
78

89
# WebdriverIO Integration
910

10-
:::note Important
11-
Access to this feature is currently limited to Enterprise customers as part of our commitment to providing tailored solutions. We are excited to announce that self-service access is under development and will be released shortly. Stay tuned!
12-
:::
11+
<EnterpriseNote />
1312

1413
## Introduction
1514

sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,6 +1707,7 @@ module.exports = {
17071707
'visual-testing/integrations/nightwatch',
17081708
'visual-testing/integrations/storybook',
17091709
'visual-testing/integrations/webdriverio',
1710+
'visual-testing/integrations/python',
17101711
],
17111712
},
17121713
'visual-testing/faq',

0 commit comments

Comments
 (0)