Axe Core
You can include accessibility tests within your WebdriverIO test suite using the open-source accessibility tools from Deque called Axe. The setup is very easy, all you need to do is to install the WebdriverIO Axe adapter via:
- npm
- Yarn
- pnpm
npm install -g @axe-core/webdriverio
yarn global add @axe-core/webdriverio
pnpm add -g @axe-core/webdriverio
Адаптер Axe можна використовувати або в автономному чи testrunner режимах, просто імпортувавши та ініціалізувавши його за допомогою об’єкта браузера, як показано тут:
import { browser } from '@wdio/globals'
import AxeBuilder from '@axe-core/webdriverio'
describe('Accessibility Test', () => {
it('should get the accessibility results from a page', async () => {
const builder = new AxeBuilder({ client: browser })
await browser.url('https://testingbot.com')
const result = await builder.analyze()
console.log('Acessibility Results:', result)
})
})
Додаткову документацію про адаптер Axe для WebdriverIO можна знайти на GitHub.