Skip to content

Commit a473fb0

Browse files
Merge pull request #22 from wswebcreation/feat/accessibility-lines
Feat/accessibility lines
2 parents 7ba09f6 + c186ea8 commit a473fb0

27 files changed

+306
-144
lines changed

.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ module.exports = {
1212
$: true,
1313
$$: true,
1414
browser: true,
15+
expect: true,
16+
describe: true,
17+
it: true,
18+
beforeEach: true,
1519
},
1620
parser: 'babel-eslint',
1721
parserOptions: {

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ before_script:
1616
- npm install
1717

1818
script:
19+
- npm run lint
1920
- npm run compile
2021
- npm run test.unit.coverage
2122
- npm run test.saucelabs

README.md

Lines changed: 60 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ You can:
2929
- increase the element dimensions screenshots
3030
- use different comparison methods
3131
- **NEW:** We now support Puppeteer with WebdriverIO
32+
- **NEW:** You can now verify how your website will support tabbing with your keyboard, see also [here](./README.md#tabbing-through-a-website)
3233
- and much more, see the [options here](./docs/OPTIONS.md)
3334

3435
The module is now based on the power of the new [`webdriver-image-comparison`](https://github.com/wswebcreation/webdriver-image-comparison) module. This is a lightweight module to retrieve the needed data and screenshots for all browsers / devices.
@@ -82,6 +83,18 @@ exports.config = {
8283
blockOutToolBar: true,
8384
// NOTE: When you are testing a hybrid app please use this setting
8485
isHybridApp: true,
86+
// Options for the tabbing image
87+
tabbableOptions:{
88+
circle:{
89+
size: 18,
90+
fontSize: 18,
91+
// ...
92+
},
93+
line:{
94+
color: '#ff221a', // hex-code or for example words like `red|black|green`
95+
width: 3,
96+
},
97+
}
8598
// ... more options
8699
}],
87100
],
@@ -91,11 +104,6 @@ exports.config = {
91104

92105
More plugin options can be found [here](./docs/OPTIONS.md#plugin-options).
93106

94-
### DEV-TOOLS support
95-
You can also use the Chrome DevTools as automation protocol in combination with this module. You don't need to do anything,
96-
just change `automationProtocol: 'devtools'` in your config.
97-
More information about how to use the DEV-TOOLS can be found in [this](https://webdriver.io/blog/2019/09/16/devtools.html) blog post.
98-
99107
### Writing tests
100108
*wdio-image-comparison-service* is framework agnostic, meaning that you can use it with all the frameworks WebdriverIO supports like `Jasmine|Mocha`.
101109
You can use it like this:
@@ -108,24 +116,30 @@ describe('Example', () => {
108116

109117
it('should save some screenshots', () => {
110118
// Save a screen
111-
browser.saveScreen('examplePaged', { /* some options*/ });
119+
browser.saveScreen('examplePaged', { /* some options */ });
112120

113121
// Save an element
114-
browser.saveElement($('#element-id'), 'firstButtonElement', { /* some options*/ });
122+
browser.saveElement($('#element-id'), 'firstButtonElement', { /* some options */ });
123+
124+
// Save a full page screenshot
125+
browser.saveFullPageScreen('fullPage', { /* some options */ });
115126

116-
// Save a full page screens
117-
browser.saveFullPageScreen('fullPage', { /* some options*/ });
127+
// Save a full page screenshot with all tab executions
128+
browser.saveTabbablePage('save-tabbable', { /* some options, use the same options as for saveFullPageScreen */ });
118129
});
119130

120131
it('should compare successful with a baseline', () => {
121132
// Check a screen
122-
expect(browser.checkScreen('examplePaged', { /* some options*/ })).toEqual(0);
133+
expect(browser.checkScreen('examplePaged', { /* some options */ })).toEqual(0);
123134

124135
// Check an element
125-
expect(browser.checkElement($('#element-id'), 'firstButtonElement', { /* some options*/ })).toEqual(0);
136+
expect(browser.checkElement($('#element-id'), 'firstButtonElement', { /* some options */ })).toEqual(0);
126137

127-
// Check a full page screens
128-
expect(browser.checkFullPageScreen('fullPage', { /* some options*/ })).toEqual(0);
138+
// Check a full page screenshot
139+
expect(browser.checkFullPageScreen('fullPage', { /* some options */ })).toEqual(0);
140+
141+
// Check a full page screenshot with all tab executions
142+
expect(browser.checkTabbablePage('check-tabbable', { /* some options, use the same options as for checkFullPageScreen */ })).toEqual(0);
129143
});
130144
});
131145
```
@@ -184,9 +198,40 @@ const checkResult = {
184198

185199
See the [Check output on failure](./docs/OUTPUT.md#check-output-on-failure) section in the [output](./docs/OUTPUT.md) docs for the images.
186200

187-
### Typescript support
201+
### Tabbing through a website
202+
We now support checking if a website is accessible through using the keyboards `TAB`-key. Testing this part of accessibility has always been a time consuming (manual) job and pretty hard to do through automation.
203+
With the methods `saveTabbablePage` and `checkTabbablePage` you can now draw lines and dots on your website to verify the tabbing order.
204+
205+
Be aware of the fact that this is only useful for desktop browser and **NOT** for mobile devices. All desktop browsers are supporting this feature, see the browser matrix on the top of this page to check which desktop browsers and versions are supported.
206+
207+
> **NOTE:**<br>
208+
> The work is inspired by [Viv Richards](https://github.com/vivrichards600) his blog post about ["AUTOMATING PAGE TABABILITY (IS THAT A WORD?) WITH VISUAL TESTING"](https://vivrichards.co.uk/accessibility/automating-page-tab-flows-using-visual-testing-and-javascript).<br>
209+
> The way tabbable elements are selected are based on the module [tabbable](https://github.com/davidtheclark/tabbable). If there are any issues regarding the tabbing please check the [README.md](https://github.com/davidtheclark/tabbable/blob/master/README.md) and especially the [More details](https://github.com/davidtheclark/tabbable/blob/master/README.md#more-details)-section.
210+
211+
#### How does it work
212+
Both methods will create a `canvas` element on your website and draw lines and dots to show you where your TAB would go if an end-user would use it. After that it will create a full page screenshot to give you a good overview of the flow.
188213

189-
Library supports typescript types. To your `tsconfig.json` add the following entry to `types`:
214+
> **Use the `saveTabbablePage` only when you need to create a screenshot and DON'T want to compare it with a base line image.**
215+
216+
When you want to compare the tabbing flow with a baseline, then you can use the `checkTabbablePage`-method. You **DON'T** need to use the two methods together. If there is already a baseline image created, which can automatically be done by providing `autoSaveBaseline: true` when you instantiate the service,
217+
the `checkTabbablePage` will first create the *actual* image and then compare it against the baseline.
218+
219+
##### Options
220+
Both methods use the same options as the [`saveFullPageScreen`](https://github.com/wswebcreation/webdriver-image-comparison/blob/master/docs/OPTIONS.md#savefullpagescreen-or-savetabbablepage) or the
221+
[`compareFullPageScreen`](https://github.com/wswebcreation/webdriver-image-comparison/blob/master/docs/OPTIONS.md#comparefullpagescreen-or-comparetabbablepage).
222+
223+
#### Example
224+
This is an example of how the tabbing works on the website of our amazing sponsor [Sauce Labs](https://www.saucelabs.com):
225+
226+
![Sauce Labs tabbing example](./docs/images/tabbable-sauce-labs-chrome-latest-1366x768.png)
227+
228+
### DEV-TOOLS support
229+
You can also use the Chrome DevTools as automation protocol in combination with this module. You don't need to do anything,
230+
just change `automationProtocol: 'devtools'` in your config.
231+
More information about how to use the DEV-TOOLS can be found in [this](https://webdriver.io/blog/2019/09/16/devtools.html) blog post.
232+
233+
### Typescript support
234+
We now also support typescript types. Add the following to the `types` in your `tsconfig.json`:
190235

191236
```json
192237
{

demo.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>inputs</title>
6+
</head>
7+
<body>
8+
9+
<h2>Code example</h2>
10+
<pre>
11+
&lt;input tabindex="3"&gt;
12+
&lt;input tabindex="0"&gt;
13+
&lt;input tabindex="-1"&gt;
14+
&lt;input&gt;
15+
&lt;input tabindex="2"&gt;
16+
&lt;input tabindex="1"&gt;
17+
&lt;span tabindex="4"&gt;This wouldn’t normally receive focus (4) largest value. Next tab will give focus to the rest of tabnavigable elements in code source order.&lt;/span&gt;
18+
&lt;a href="#" &gt;Link 1&lt;/a&gt;
19+
&lt;a href="#"&gt;Link 2&lt;/a&gt;
20+
&lt;a href="#"&gt;Link 3&lt;/a&gt;
21+
&lt;a href="#"&gt;Link 4&lt;/a&gt;
22+
</pre>
23+
24+
<br><br>
25+
26+
<h2>Live elements</h2>
27+
<p>
28+
<input tabindex="3"> (3) Will receive focus third<br><br>
29+
<input tabindex="0" style="margin-left: 50px"> (0) In normal source order<br><br>
30+
<input tabindex="-1" style="margin-left: 0"> (-1) Will not receive focus<br><br>
31+
<input> (n/a) In normal source order<br><br>
32+
<input tabindex="2" style="margin-left: 20px"> (2) Will receive focus second<br><br>
33+
<input tabindex="1" style="margin-left: 0"> (1) Will receive focus first<br><br>
34+
<span tabindex="4" style="margin-left: 40px">This wouldn’t normally receive focus</span>
35+
(4) largest value. Next tab will give focus to the
36+
rest of tabnavigable elements in code source order.<br><br>
37+
<a href="#" style="margin-left: 0">Link 1</a><br><br>
38+
<a href="#" style="margin-left: 20px">Link 2</a><br><br>
39+
<a href="#" style="margin-left: 30px">Link 3 </a><br><br>
40+
<a href="#" style="margin-left: 40px">Link 4</a><br><br>
41+
</p>
42+
</body>
43+
</html>
1.6 MB
Loading

lib/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import WdioICS from './service';
1+
import WdioICS from './service'
22

3-
export default WdioICS;
3+
export default WdioICS

0 commit comments

Comments
 (0)