Axe Core
WebdriverIOテストスイート内に、Deque社が提供するAxeと呼ばれるオープンソースのアクセシビリティツールを使用してアクセシビリティテストを含めることができます。セットアップは非常に簡単で、WebdriverIO Axeアダプタをインストールするだけです:
- npm
- Yarn
- pnpm
npm install -g @axe-core/webdriverio
yarn global add @axe-core/webdriverio
pnpm add -g @axe-core/webdriverio
Axeアダプタは、ブラウザオブジェクトを使って簡単にインポートして初期化することで、スタンドアロンまたはテストランナーモードのどちらでも使用できます。例:
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で確認できます。