跳至主要內容

Axe Core

您可以使用 Deque 開源的輔助功能工具 Axe,將輔助功能測試納入您的 WebdriverIO 測試套件中。設定非常容易,您只需透過以下方式安裝 WebdriverIO Axe 轉接器:

npm install -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 轉接器的文件。

歡迎!我能幫您什麼嗎?

WebdriverIO AI Copilot