Skip to content

Instantly share code, notes, and snippets.

@marcysutton
Last active June 6, 2016 21:43
Show Gist options
  • Save marcysutton/5f50df2cc18e95051547f3aebb37cc2a to your computer and use it in GitHub Desktop.
Save marcysutton/5f50df2cc18e95051547f3aebb37cc2a to your computer and use it in GitHub Desktop.
Microsoft Edge Testing with aXe

Steps to set up automated accessibility testing with Microsoft Edge

All of these steps should be completed on a Windows machine or VM. Just so you don't get confused and I don't have to keep typing Windows!

  • Download the MicrosoftEdgeDriver.msi version that most closely matches your build and put it somewhere on your PATH
  • Download and run MicrosoftEdgeDriver.exe, note the server and path running.
  • Install test dependencies with npm install.
  • Update server/path in test file to tell Webdriver where to look.
  • Run tests with npm test
{
"name": "axe-webdriverjs-demo",
"version": "1.0.0",
"description": "How to set up aXe with WebdriverJS for automated testing.",
"scripts": {
"postinstall": "./node_modules/.bin/jasmine init",
"test": "./node_modules/.bin/jasmine spec/test.js"
},
"author": {
"name": "Marcy Sutton",
"organization": "Deque Systems",
"url": "http://deque.com"
},
"license": "ISC",
"dependencies": {
"axe-core": "^1.1.1",
"axe-webdriverjs": "^0.2.0",
"jasmine": "^2.4.1",
"selenium-webdriver": "^2.48.2"
}
}
var selenium = require('selenium-webdriver'),
AxeBuilder = require('axe-webdriverjs');
var util = require('util');
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
var driver, browser;
describe('A11y Test Demo', function() {
beforeEach(function(done) {
driver = new selenium.Builder()
.usingServer('http://localhost:17556')
.forBrowser('edge')
.build();
driver.get('http://marcysutton.com')
.then(function () {
done();
});
});
// Close website after each test is run (so it is opened fresh each time)
afterEach(function(done) {
driver.quit().then(function () {
done();
});
});
it('should fetch the homepage and analyze it', function (done) {
driver.findElements(selenium.By.css('.home'))
.then(function () {
AxeBuilder(driver)
.analyze(function(results) {
console.log('Accessibility Violations: ', results.violations.length);
if (results.violations.length > 0) {
console.log(util.inspect(results.violations, true, null));
}
expect(results.violations.length).toBe(0);
done();
})
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment