Skip to content

Commit 795440d

Browse files
Ishavyas9surishubham
authored andcommitted
Merge pull request #1135 from Aman1905/stage
playwright accessibility
1 parent 2754b95 commit 795440d

File tree

3 files changed

+148
-0
lines changed

3 files changed

+148
-0
lines changed
73.9 KB
Loading
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
---
2+
id: playwright-accessibility-test
3+
title: Automation Tests with Accessibility Tool using Playwright
4+
sidebar_label: Playwright
5+
description: Use LambdaTest Accessibility DevTools with Playwright to detect and report accessibility issues with automation, following WCAG guidelines.
6+
keywords:
7+
- LambdaTest
8+
- Accessibility
9+
- Testing
10+
- Automation
11+
- Accessibility Testing Settings
12+
url: https://www.lambdatest.com/support/docs/playwright-accessibility-test/
13+
site_name: LambdaTest
14+
slug: playwright-accessibility-test/
15+
---
16+
17+
import CodeBlock from '@theme/CodeBlock';
18+
import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/component/keys";
19+
import Tabs from '@theme/Tabs';
20+
import TabItem from '@theme/TabItem';
21+
22+
<script type="application/ld+json"
23+
dangerouslySetInnerHTML={{ __html: JSON.stringify({
24+
"@context": "https://schema.org",
25+
"@type": "BreadcrumbList",
26+
"itemListElement": [{
27+
"@type": "ListItem",
28+
"position": 1,
29+
"name": "Home",
30+
"item": "https://www.lambdatest.com"
31+
},{
32+
"@type": "ListItem",
33+
"position": 2,
34+
"name": "Support",
35+
"item": "https://www.lambdatest.com/support/docs/"
36+
},{
37+
"@type": "ListItem",
38+
"position": 3,
39+
"name": "Accessibility Testing Test",
40+
"item": "https://www.lambdatest.com/support/docs/playwright-accessibility-test/"
41+
}]
42+
})
43+
}}
44+
></script>
45+
46+
This document walks you through the process of evaluating the accessibility of your website through the execution of automated tests using LambdaTest's Accessibility Tool.
47+
48+
<!-- > Compatible only with Chrome and Edge browser versions >= 90. -->
49+
50+
## Prerequisites
51+
52+
- Your [LambdaTest Username and Access key](/support/docs/using-environment-variables-for-authentication-credentials/)
53+
- Setup your local machine as per your testing framework.
54+
55+
## Step-by-Step Guide to Trigger Your Test
56+
57+
### Step 1: Setup Your Test Suite
58+
59+
You can use your own project to configure and test it. For demo purposes, we are using the sample repository.
60+
61+
:::tip sample repo
62+
Download or Clone the code sample from the LambdaTest GitHub repository to run your tests.
63+
64+
<a href="https://github.com/LambdaTest/lambdatest-accessibility-selenium" className="github__anchor"><img loading="lazy" src={require('../assets/images/icons/github.png').default} alt="Image" className="doc_img"/> View on GitHub</a>
65+
:::
66+
67+
If you are using your own project, make sure you update the **Hub endpoint** in your tests file. By setting up the Hub endpoint, you establish the communication channel between your tests and the browser nodes, enabling effective test distribution and execution.
68+
69+
Configure the desired capabilities based on your test requirements. For example:
70+
71+
```javascript
72+
const capabilities = {
73+
'browserName': 'Chrome',
74+
'browserVersion': 'latest',
75+
'LT:Options': {
76+
'platform': 'Windows 10',
77+
'build': 'Playwright Accessibility',
78+
'name': 'Playwright Accessibility',
79+
'user': process.env.LT_USERNAME,
80+
'accessKey': process.env.LT_ACCESS_KEY,
81+
..//
82+
}
83+
}
84+
```
85+
86+
> You can generate capabilities for your test requirements with the help of our inbuilt 🔗 [Capabilities Generator Tool](https://www.lambdatest.com/capabilities-generator/).
87+
88+
### Step 2: Establish User Authentication
89+
90+
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/detail/profile).
91+
92+
Run the below mentioned commands in your terminal to setup the CLI and the environment variables.
93+
94+
<Tabs className="docs__val">
95+
96+
<TabItem value="bash" label="Linux / MacOS" default>
97+
98+
<div className="lambdatest__codeblock">
99+
<CodeBlock className="language-bash">
100+
{`export LT_USERNAME="${ YOUR_LAMBDATEST_USERNAME()}"
101+
export LT_ACCESS_KEY="${ YOUR_LAMBDATEST_ACCESS_KEY()}"`}
102+
</CodeBlock>
103+
</div>
104+
105+
</TabItem>
106+
107+
<TabItem value="powershell" label="Windows" default>
108+
109+
<div className="lambdatest__codeblock">
110+
<CodeBlock className="language-powershell">
111+
{`set LT_USERNAME="${ YOUR_LAMBDATEST_USERNAME()}"
112+
set LT_ACCESS_KEY="${ YOUR_LAMBDATEST_ACCESS_KEY()}"`}
113+
</CodeBlock>
114+
</div>
115+
116+
</TabItem>
117+
</Tabs>
118+
119+
### Step 3: Configure the Necessary Capabilities
120+
121+
To enable the accessibility testing within your automated test suite, set the `accessibility: true` in your configuration file. You can also define other settings capabilities as described below.
122+
123+
```javascript
124+
const capabilities = {
125+
'LT:Options': {
126+
..//
127+
"accessibility":true,
128+
"accessibility.wcagVersion":"wcag21a",
129+
"accessibility.bestPractice":true,
130+
"accessibility.needsReview":true
131+
}
132+
}
133+
```
134+
135+
### Step 4: Execute and Monitor your Test
136+
137+
Now execute your tests and visit the [Automation Dashboard](https://accounts.lambdatest.com/dashboard). Click on the Accessibility tab and check the report generated.
138+
139+
```bash
140+
node test
141+
```
142+
143+
<img loading="lazy" src={require('../assets/images/accessibility-testing/playwright-accessibility.png').default} alt="automation-dashboard" className="doc_img"/>

sidebars.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,6 +1588,11 @@ module.exports = {
15881588
"cypress-v9-accessibility-test",
15891589
],
15901590
},
1591+
{
1592+
type: "doc",
1593+
label: 'Playwright',
1594+
id: "playwright-accessibility-test",
1595+
},
15911596
]
15921597
},
15931598
{

0 commit comments

Comments
 (0)