Skip to content

feat: add aria-busy support to role selectors #36250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

markmur
Copy link

@markmur markmur commented Jun 9, 2025

Closes #36233

Summary

This PR adds support for the aria-busy attribute to Playwright's role selector functionality, allowing developers to identify elements based on their busy state.

Changes

  • Core Implementation: Added getAriaBusy() function in roleUtils.ts that uses getAriaBoolean() to check the aria-busy attribute
  • Role Selector Engine: Added busy option support to role selector engine with proper validation
  • TypeScript Support: Added busy?: boolean property to ByRoleOptions type in locatorUtils.ts
  • Documentation: Added comprehensive documentation for the busy option in API docs
  • Testing: Added thorough tests covering all busy attribute scenarios

Usage Examples

API syntax:

// Find busy buttons
await page.getByRole('button', { busy: true }).click();

// Find non-busy buttons  
await page.getByRole('button', { busy: false }).click();

Behavior

  • Elements without an aria-busy attribute are treated as busy=false (following ARIA specification)
  • Elements with aria-busy="true" are treated as busy=true
  • Elements with aria-busy="false" are treated as busy=false
  • The busy attribute can be applied to any role (no role restrictions, following ARIA global attribute guidelines)

Testing

All tests pass including:

  • ✅ Basic busy/non-busy element detection
  • ✅ Selector syntax (role=button[busy], role=button[busy=true], role=button[busy=false])
  • ✅ API syntax (getByRole('button', { busy: true }))
  • ✅ Default behavior for elements without aria-busy attribute
  • ✅ Integration with existing role selector functionality
  • ✅ Error handling and validation

The implementation follows the same patterns as existing ARIA attributes (checked, disabled, selected, etc.) and maintains full backward compatibility.

Copy link
Contributor

github-actions bot commented Jun 9, 2025

Test results for "tests 1"

4 flaky ⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:986:7 › cli codegen › should not throw csp directive violation errors @firefox-ubuntu-22.04-node18
⚠️ [playwright-test] › ui-mode-trace.spec.ts:587:5 › should indicate current test status @macos-latest-node18-1
⚠️ [webkit-page] › page/page-screenshot.spec.ts:345:5 › page screenshot › should work while navigating @webkit-ubuntu-22.04-node18
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all @windows-latest-node18-1

39360 passed, 820 skipped
✔️✔️✔️

Merge workflow run.

@markmur
Copy link
Author

markmur commented Jun 9, 2025

@microsoft-github-policy-service agree

@Skn0tt
Copy link
Member

Skn0tt commented Jun 23, 2025

Hi! We're trying to be mindful of expanding your API scope, so we need to have clear indicators for user need before we make additions like these. Let's wait a while to see how many upvotes #36233 gathers. If it turns out being a popular request, we're more than happy to accept a PR.

@markmur
Copy link
Author

markmur commented Jun 23, 2025

Sounds good, thanks @Skn0tt 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: Add busy option to getByRole method
2 participants