Axe Core
您可以使用Deque公司的开源可访问性工具Axe在WebdriverIO测试套件中包含可访问性测试。设置非常简单,您只需要通过以下方式安装WebdriverIO Axe适配器:
- npm
- Yarn
- pnpm
npm install -g @axe-core/webdriverio
yarn global add @axe-core/webdriverio
pnpm add -g @axe-core/webdriverio
Axe适配器可以在独立模式或测试运行器模式下使用,只需简单地导入并使用browser对象初始化它,例如:
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)
})
})
您可以在GitHub上找到有关Axe WebdriverIO适配器的更多文档。