Skip to content

Instantly share code, notes, and snippets.

@manoj9788
Created April 15, 2019 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manoj9788/eb66e2bdf9bde0178b1d2d1b1bc404b0 to your computer and use it in GitHub Desktop.
Save manoj9788/eb66e2bdf9bde0178b1d2d1b1bc404b0 to your computer and use it in GitHub Desktop.
import selenium from 'selenium-webdriver';
import AxeBuilder from 'axe-webdriverjs';
const Key = selenium.Key;
import util from 'util';
let driver;
describe('Radio button demo', () => {
beforeEach(done => {
driver = new selenium.Builder()
.forBrowser('chrome')
.build();
driver.get('http://localhost:4000/radio/')
.then(() => {
done();
});
});
// Close website after each test is run (so it is opened fresh each time)
afterEach(done => {
driver.quit().then(() => {
done();
});
});
it('should change state with the keyboard', () => {
const selector = 'span[role="radio"][aria-labelledby="radiogroup-0-label-0"]';
driver.findElement(selenium.By.css(selector))
.then(element => {
element.sendKeys(Key.SPACE);
return element;
})
.then(element => element.getAttribute('aria-checked'))
.then(attr => {
expect(attr).toEqual('true');
});
});
it('should fetch the radio button demo and analyze it', done => {
driver.findElement(selenium.By.css('.radio_'))
.then(() => {
AxeBuilder(driver)
.analyze(({violations}) => {
console.log('Accessibility Violations: ', violations.length);
if (violations.length > 0) {
console.log(util.inspect(violations, true, null));
}
expect(violations.length).toBe(0);
done();
})
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment