pa11y / pa11y-ci

Pa11y CI is a CI-centric accessibility test runner, built using Pa11y
https://pa11y.org
GNU Lesser General Public License v3.0
525 stars 63 forks source link

Pa11y overrides the specific default HideElements configuration for each individual URL #66

Open lsigism opened 6 years ago

lsigism commented 6 years ago

Hello pa11y team πŸ‘‹ how are you?

I am a QA engineer trying to use Pa11y in our framework to improve the accessibility levels for our projects. I am really enjoying this tool so far. But today I came across a specific case that is the reason of this 'issue', or as I might say "an improvement".

Let's consider the following .pa11yci config file:

{ "defaults": { "timeout": 1000, "hideElements": ".hiddingAGlobalElement", ".alsoHiddingAnotherGlobalOne" }, "urls": [ "http://pa11y.org/", { "url": "http://pa11y.org/contributing", "hideElements": ".advert, #modal, div[aria-role=presentation]" }, { "url": "http://pa11y.org/news/", "hideElements": ".someOtherElement, #ignoreMe" ] } ] }

When I run it, Pa11y seems to be overriding the local hideElements values when I have a global HideElements defined. And in my current example I would like to have global HideElements as they appear for every page I am testing, but also I would like to hide unique elements (that are not conform with the accessibility standards) for every page I am testing.

A current workaround is duplicating every global HideElement for each individual URLs (what I think it's not great).

Let me know if you need more info and please share your thoughts about this suggestion πŸ˜„

Thank you guys πŸ‘

hollsk commented 6 years ago

This issue reminded me of https://github.com/pa11y/pa11y/issues/178 which is a similar kind of idea.

Maybe we could add a second rules block called globals, that overrides defaults, but is additive with following rules instead of a straight replacement. So something like this:

{
    "defaults": {
        "timeout": 1000
    },
    "globals": {
        "timeout": 50000,
        "ignore": "issue-code-1",
        "hideElements": ".hiddingThisGlobalElement, .alsoThisOne"
    },
    "urls": [
        "http://pa11y.org/",
        {
            "url": "http://pa11y.org/contributing",
            "hideElements": ".advert, #modal, div[aria-role=presentation]" ,
            "ignore": "issue-code-2"
        }
    ]
}

for all URLs by default would run pa11y with these parameters:

--timeout 50000 --ignore issue-code-1 --hide-elements ".hiddingThisGlobalElement, .alsoThisOne"

and for pa11y.org/contributing it would run with these parameters:

--timeout 50000 --ignore "issue-code-1;issue-code-2" --hide-elements ".hiddingThisGlobalElement, .alsoThisOne, .advert, #modal, div[aria-role=presentation]"

Edit: We'd need to make sure people don't try to do something like --timeout 1000 50000 - only some rules can be additive πŸ€”

Thoughts? @andrewmee etc?