DEV Community

A11Y Practice
A11Y Practice

Posted on Originally published at wasexamprep.com

Testing Tab Structure: When axe and Chrome Disagree About Your tablist

The wrong one passes

I ran axe-core 4.14.0 on the Broken Example of the Tablist Roles lab on 14 November 2026, scoped to that example, with the WCAG 2.0, 2.1 and 2.2 A/AA tags plus best practices. It reported exactly one violation: aria-required-parent, "Required ARIA parent role not present: tablist", on two tabs.

Those two tabs are the half-fixed case: role="tab" and aria-selected are present, but there is no tablist around them. The other broken case, plain buttons styled as tabs with no tab semantics at all, produced no violation.

The companion blog explains why a tab needs its parent. This article is about testing it: what to assert, a small helper that checks Chrome's accessibility tree, seven test pages, and the places where axe and Chrome disagree.

Everything here is one browser, one tool version and one day. The runs are real; the conclusions are scoped to them.

What to assert

The ARIA rule is short. WAI-ARIA 1.2 says: "Authors MUST ensure elements with role tab are contained in, or owned by, an element with the role tablist." Turn that into checks you can run:

  1. Every element exposed with role tab has, as its nearest meaningful ancestor in the accessibility tree, a tablist.
  2. That tablist has a non-empty accessible name. The APG Tabs pattern says to use aria-labelledby when the tab list has a visible label, and aria-label otherwise. This is guidance, but it is cheap to assert.
  3. Every tab is checked, not just the first one.

"Nearest meaningful ancestor" means walking up the tree and skipping nodes that carry no semantics: ignored nodes, generic, none and presentation. A wrapper div between the tablist and a tab is fine. A wrapper that replaces the tablist is not.

Assert against the browser's computed tree, not the DOM. A DOM check such as tab.closest('[role=tablist]') misses aria-owns, and it cannot tell you how the browser actually treated wrapper elements. That second point turns out to matter.

The helper

This helper uses Playwright and the Chrome DevTools Protocol to read the full accessibility tree, then returns one row per tab with the role and name of its nearest meaningful ancestor.

async function tabStructure(page) {
  const cdp = await page.context().newCDPSession(page);
  const { nodes } = await cdp.send('Accessibility.getFullAXTree');
  await cdp.detach();
  const byId = new Map(nodes.map((n) => [n.nodeId, n]));
  const parentOf = new Map();
  for (const n of nodes) for (const id of n.childIds ?? []) parentOf.set(id, n.nodeId);
  const role = (n) => n?.role?.value;
  const skip = (n) => n.ignored || ['generic', 'none', 'presentation'].includes(role(n));
  return nodes
    .filter((n) => !n.ignored && role(n) === 'tab')
    .map((tab) => {
      let a = byId.get(parentOf.get(tab.nodeId));
      while (a && skip(a)) a = byId.get(parentOf.get(a.nodeId));
      return { tab: tab.name?.value ?? '', parentRole: role(a), parentName: a?.name?.value ?? '' };
    });
}
Enter fullscreen mode Exit fullscreen mode

In a Playwright test, the assertion is then one line per rule:

const rows = await tabStructure(page);
expect(rows.filter((r) => r.parentRole !== 'tablist')).toEqual([]);
expect(rows.filter((r) => r.parentName === '')).toEqual([]);
Enter fullscreen mode Exit fullscreen mode

Run against the live lab on 14 November 2026 (headless Chromium 156), the helper returned two rows whose parent was the Broken Example region, not a tablist: the Case 2 tabs. The four fixed-case tabs returned tablists named Settings and Preferences. The plain buttons in Case 1 return no rows at all, because Chrome exposes them as buttons. That is the limit of any tab-structure test: it cannot find tabs that were never marked up as tabs.

Scope the helper to one widget when a page has several tab sets, and keep the CDP part in end-to-end tests. A unit test on rendered HTML cannot tell you what Chrome computed.

Seven test pages, two tools

To see how wrappers behave, I built seven tiny local test pages, each with two tabs, Account and Notifications, and ran both the helper and axe-core 4.14.0 on each one (14 November 2026, headless Chromium 156.0.8078.4).

Test page Chrome: nearest meaningful ancestor of the tabs axe-core structural result
F1: tabs in a plain div the surrounding region, no tablist aria-required-parent on both tabs
F2: tabs directly in div role="tablist" tablist "Preferences" none
F3: ul role="tablist" with each tab in an li tablist "Preferences"; the li was exposed as none and ignored aria-required-children, aria-required-parent on both tabs, listitem on both li
F4: same, with role="presentation" on each li tablist "Preferences" none
F5: tablist, then a plain div around each tab tablist "Preferences"; the div was generic none
F6: Account inside the tablist, Notifications in a sibling div Account: tablist; Notifications: the region aria-required-parent on Notifications
F7: tablist with no name tablist with an empty name none

The unstyled test buttons also triggered axe's target-size rule (WCAG 2.5.8) on every page. That is an artifact of the bare test markup, not part of this lesson.

Three things stand out. F3 is where the tools disagree: Chrome treated the list items as presentational and built a clean tree, while axe still reported three rules. F6 is the refactor bug: one tab quietly leaves the set while both still look identical. F7 passes axe completely, so naming is a manual or custom check.

Common mistakes, and the check that catches each one

Adding role=tab and forgetting the wrapper. This is lab Broken Case 2 and test page F1. Both the helper and axe catch it. It is also the easiest one to ship, because every tab looks correct when you inspect it alone.

Styling plain buttons as tabs. Lab Broken Case 1. axe passed it in our run, and the helper finds no tabs at all. Only a review that compares what the screen shows with what the tree exposes catches it. Put "does anything look like tabs but expose as buttons?" on your manual checklist.

Using list markup for tabs. Test page F3. In this Chromium build the list items were treated as presentational and the tree looked clean, but axe still reported aria-required-children, aria-required-parent and listitem. Adding role="presentation" to each li (F4) made the tree and axe agree. I have not tested other browsers or screen readers on F3, so treat the role="presentation" version as the unambiguous one rather than relying on how one browser repairs the markup.

Splitting the tab set during a refactor. Test page F6. A layout change moves one tab into another container. Assert on every tab, not just the first, or the test passes while one tab is orphaned.

Leaving the tablist unnamed. Test page F7. No axe violation. Assert a non-empty name in your own test, and prefer aria-labelledby when there is a visible heading for the tab set.

Expecting the tablist to add keyboard behavior. It does not. In the lab's fixed cases, Tab still moves from tab to tab, and there are no arrow keys. The single Tab stop and arrow keys are a separate implementation, covered in The Tab Your Keyboard Can't Reach.

Reporting the rule name as the finding. "aria-required-parent" is not a WCAG success criterion. Map what you found: tabs presented as one set but not grouped is a 1.3.1 Info and Relationships question; controls presented as tabs that expose as buttons with only visual selection is a 4.1.2 Name, Role, Value question. The ARIA MUST and the APG guidance support the finding; they are not the criterion.

Real VoiceOver captures

The lab stores its own VoiceOver on Mac captures, dated 12 June 2026 (OS and VoiceOver versions were not recorded):

  • Broken Case 2, Account: Account, selected, tab
  • Fixed Case 2, Account: Account, selected, tab, 1 of 2, Preferences, tab group

Only the container changed between those two cases, and the count and group name appeared. Note that Chrome's tree, in our capture, carried no position or set-size field on the tabs. The "1 of 2" is what VoiceOver spoke, not a tree value.

No VoiceOver captures were made for the seven test pages, so this article makes no claim about how VoiceOver announces them, including the list-item version.

What each check can establish

  • The structure helper: the tree shape Chrome computed, in one browser.
  • axe-core: the rules it knows about, including some Chrome silently repairs.
  • A manual review: tabs that exist only visually, which neither tool sees.
  • A VoiceOver capture: what one screen reader said in one setup, on one date.

None of them alone establishes WCAG conformance. Together they tell you what is missing and where to look.

Keep practicing

Practice this in the Tablist Roles lab on wasexamprep.com, and review Custom Widgets for the related WAS rules.

Watch the full walkthrough and subscribe to the A11Y in Practice YouTube channel for more hands-on accessibility episodes.

A11Y in Practice and wasexamprep.com are independent educational resources. They are not affiliated with or endorsed by IAAP (International Association of Accessibility Professionals).

Top comments (0)