dequelabs / axe-core

Accessibility engine for automated Web UI testing
https://www.deque.com/axe/
Mozilla Public License 2.0
5.75k stars 746 forks source link

landmark-unique seems to contradict W3C spec #4447

Open TimCanu opened 1 month ago

TimCanu commented 1 month ago

Product

playwright

Product Version

4.9.0

Latest Version

Issue Description

Expectation

Here is a code pen on which the issue is detailed. I don't know how to easily share this with playwright but a code like the following should yield the same error:

await page.goto('https://codepen.io/TimCanYou/pen/mdgNyRz')
const accessibilityScanResults = await new AxeBuilder({ page }).exclude("").analyze()
expect(accessibilityScanResults.violations).toEqual([]) 

I have a table showing data. Above and below the table are one navigation landmark (both are identical). In such a situation, according to W3C: If a specific landmark role is used more than once on a page, provide each instance of that landmark with a unique label. There is one rare circumstance where providing the same label to multiple instances of a landmark can be beneficial: the content and purpose of each instance is identical. For example, a large search results table has two sets of identical pagination controls -- one above and one below the table, so each set is in a navigation region labelled Search Results. In this case, adding extra information to the label that distinguishes the two instances may be more distracting than helpful. So I don't expect the error "landmark-unique" for my <nav>s having the same aria-label...

Actual

I have the error "landmark-unique": https://dequeuniversity.com/rules/axe/4.9/landmark-unique?application=playwright

How to Reproduce

code pen

If you consider that this is expected and wanted behaviour, what is your recommendation in such a case?

straker commented 1 month ago

Thanks for the issue. This is an axe-core issue so I'm going to transfer it there.

WilcoFiers commented 1 month ago

@TimCanu Thank you for reporting this. I agree with you, this is a reasonable exception that we didn't account for in the rule. Is this something you encountered on a live website?

TimCanu commented 1 month ago

Hello @WilcoFiers This is something I encountered on a personal project (so not really live as it is a WIP)