Playwrightでのエラーハンドリング

This page is not available in the language you requested. You have been redirected to the English version of the page.
Link to this page copied to clipboard

PlaywrightにおけるAxe DevTools for Webで発生する可能性のあるエラーを回避する方法

Not for use with personal data

Axe DevTools for Webの統合バージョン4.3.0以降では、AxeBuilder.analyze()時に新しい技術を使用しており、実行の最後に新しいウィンドウを開きます。このドキュメントで説明する多くの問題は、この技術に関する一般的な問題とその潜在的な解決策に対応しています。

ポップアップブロッカーが有効な場合

ポップアップブロッカーは、AxeBuilder.analyze()時に新しいウィンドウを開くのを妨げます。ほとんどの自動テストライブラリのデフォルト設定では、ポップアップが許可される必要があります。テストを実行する際に問題が発生しないように、ポップアップブロッカーを明示的に有効にしないようにしてください。

AxeBuilder.setLegacyMode(legacy: boolean)

何らかの理由で新しいAxeBuilder.analyze技術をエラーなく実行できない場合、axeはAxeBuilder.analyzeのレガシーバージョンを実行できる新しいチェイン可能メソッドを提供します。このメソッドを使用すると、axeはクロスドメインフレームやiframeで発生する可能性のあるアクセシビリティ問題を除外します。

note

AxeBuilder.setLegacyModeは廃止予定で、v5.0で削除されます。レガシーバージョンが削除される前に修正できるよう、AxeBuilder.analyzeの実行中に発生するエラーを報告してください。

const { AxeDevToolsBuilder } = require('@axe-devtools/playwright')
const playwright = require('playwright')

;(async () => {
  const browser = await playwright.chromium.launch()
  const context = await browser.newContext()
  const page = await context.newPage()
  await page.goto('https://dequeuniversity.com/demo/mars/')

  try {
    const results = await new AxeDevToolsBuilder({ page }).setLegacyMode().analyze();
    console.log(results)
  } catch (e) {
    // do something with the error
  }
  await browser.close()
})()