首页 > 解决方案 > pa11y-ci 找不到 HTML 元素

问题描述

我正在尝试测试我正在使用 pa11y 开发的网站的登录体验的可访问性。我正在使用带有以下配置的 pa11y-ci,但似乎无法使其工作:

{
   "urls": [
    {
      "url": "https://somewhere/home",
      "actions": [
        "set field #email to jondoe@somewhere.com",
        "click element #passwordsignin",
        "wait for url to be https://somewhere/password"
      ],
      "timeout": 60000
    }
  ]
}

它失败并出现以下错误:

Error: Failed action: no element matching selector "#email"

我可以看到带有 id #email 的输入在 HTML 中(基于代码并检查 HTML)。我怀疑问题在于测试是在 DOM 中呈现输入之前运行的(它是用 React 编写的单页应用程序)。我尝试在操作中添加如下内容:

"wait for element #email to be added"

但它没有用。我收到以下错误:

Error: Evaluation failed: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src 'self'".

at new Function (<anonymous>)
at waitForPredicatePageFunction (<anonymous>:2:21)

任何帮助将不胜感激,非常感谢。

(仅供参考,我可以毫无问题地运行此处列出的示例)

标签: pa11y

解决方案


推荐阅读