1

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'
],
Adamantus
  • 813
  • 1
  • 12
  • 30

2 Answers2

3

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!
José Luis
  • 1,816
  • 8
  • 24
  • 26
-2

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

Adamantus
  • 813
  • 1
  • 12
  • 30