【问题标题】:Pa11y actions reference / documentationPa11y 操作参考/文档
【发布时间】:2022-08-10 23:01:34
【问题描述】:

如何输入值以匹配 name=\"\" 属性或 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\'
],

    标签: pa11y


    【解决方案1】:

    来自the documentation that you linked(强调我的):

    这允许您通过传入来单击元素一个 CSS 选择器.此操作采用 click element 形式。
    [...]
    您可以使用任何有效的query selector,包括类和类型。

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

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

    使用 --debug 标志运行 pa11y 应该可以帮助您了解操作是否正常工作。对于上面的示例,您应该能够看到类似于以下的输出:

    
    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!
    

    【讨论】:

      【解决方案2】:

      我找到了操作参考,尽管该项目的文档非常有限。据我所知,选择器似乎仅限于 ID,如果没有的话,也不是很好。我希望 Selenium 类型的选择器包括 Xpath。

      Pa11y Documentation - Actions

      【讨论】:

        猜你喜欢
        • 2012-07-30
        • 1970-01-01
        • 1970-01-01
        • 2021-03-25
        • 2023-03-20
        • 1970-01-01
        • 2019-08-14
        • 2018-03-21
        • 2020-04-26
        相关资源
        最近更新 更多