PA11Y动作参考 /文档

发布于 2025-02-13 22:14:53 字数 294 浏览 0 评论 0原文

您如何输入值匹配名称=“”属性,还是class =“”?我猜想#指的是ID =“”?如果没有HTML ID属性,则需要一种匹配其他属性或元素本身的方法。

是否有有关如何使用动作的参考?

actions: [
    'set field #login_field to abc',
    'set field #password to defghi',
    'click element #password"',
    'wait for url to be http://github.com'
],

How do you enter values to match a name="" attribute, or class=""? I'm guessing that # is referring to id="" only? If HTML ID attributes are not available there needs to be a way to match other attributes or the element itself.

Is there a reference for how to use actions?

actions: [
    'set field #login_field to abc',
    'set field #password to defghi',
    'click element #password"',
    'wait for url to be http://github.com'
],

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不如归去 2025-02-20 22:14:53

来自您链接的文档

这使您可以通过传递 a CSS选择器单击一个元素。此操作采用表单单击元素。
[...]
您可以使用任何有效的 Query selector 包括类,包括类和类型。

您应该能够使用任何有效的CSS选择器,包括ID,类和更复杂的CSS选择器。例如,要单击具有class =“ myClass”的元素,您可以使用:

{
    "actions": [
        "click element .myClass",
        "wait for path to be /foo"
    ]
}

使用运行PA11Y - debug flag应该帮助您了解该操作是否正常工作。对于像上面的示例,您应该能够看到与此类似的输出:


Welcome to Pa11y

 > Running Pa11y on URL https://www.example.com/
[...]
 > Running actions
 > Debug: Running action: click element .myClass
 > Debug:   ✔︎ Action complete: click-element
 > Debug: Running action: wait for path to be /foo
 > Debug:   ✔︎ Action complete: wait-for-url
 > Finished running actions
[...]
 > Debug: Document title: "Foo"

No issues found!

From the documentation that you linked (emphasis mine):

This allows you to click an element by passing in a CSS selector. This action takes the form click element .
[...]
You can use any valid query selector, including classes and types.

You should be able to use any valid CSS selector, including IDs, classes, and more complex CSS selectors. For example, to click on an element with class="myClass" you could use:

{
    "actions": [
        "click element .myClass",
        "wait for path to be /foo"
    ]
}

Running pa11y using the --debug flag should help you understand if the actions are working correctly. For an example like the one above you should be able to see an output similar to this:


Welcome to Pa11y

 > Running Pa11y on URL https://www.example.com/
[...]
 > Running actions
 > Debug: Running action: click element .myClass
 > Debug:   ✔︎ Action complete: click-element
 > Debug: Running action: wait for path to be /foo
 > Debug:   ✔︎ Action complete: wait-for-url
 > Finished running actions
[...]
 > Debug: Document title: "Foo"

No issues found!
你的心境我的脸 2025-02-20 22:14:53

我找到了动作参考,尽管该项目的文档非常有限。据我所知,选择器似乎仅限于ID,如果没有的话,没有什么好。我希望硒型Selectors Inc X Path。

pa11y文档 - 操作

I found the actions reference, although the documentation is very limited for this project. Selectors seem limited to IDs as far as I can tell, not much good if there aren't any. I was hoping for Selenium-type selectors inc Xpath.

Pa11y Documentation - Actions

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文