I did this a little while ago, but thought it was neat so I wanted to write about it. I found that Duque’s Axe tool was available as an npm module so I decided to integrate into Mediawiki’s Growth Experiments extension as an example for how these sorts of checks can be implemented.
var assert = require( 'assert' ),
HomepagePage = require( '../pageobjects/homepage.page' ),
LoginPage = require( 'wdio-mediawiki/LoginPage' ),
Api = require( 'wdio-mediawiki/Api' ),
Util = require( 'wdio-mediawiki/Util' ),
aXe = require( 'wdio-axe' );
describe( 'Homepage', function () {
let password, username, bot;
before( async () => {
bot = await Api.bot();
} );
beforeEach( function () {
username = Util.getTestString( 'NewUser-' );
password = Util.getTestString();
browser.call( async () => {
await Api.createAccount( bot, username, password );
} );
LoginPage.login( username, password );
} );
it( 'has no accessibility violations', function () {
HomepagePage.open();
const result = aXe.getViolations();
console.log( result );
assert( HomepagePage.homepage.isExisting() );
assert.strictEqual( result.violations[ 0 ].result, 'No Violations found in this page' );
} );
} );