Created
April 15, 2019 23:18
-
-
Save manoj9788/eb66e2bdf9bde0178b1d2d1b1bc404b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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