* Handles role locator objects by converting them to Playwright's getByRole() API * Accepts both raw objects ({role: 'button', text: 'Submit'}) and Locator-wrapped role objects. * Returns elements array if role locator, null otherwise
(context, locator)
| 4199 | * Returns elements array if role locator, null otherwise |
| 4200 | */ |
| 4201 | async function handleRoleLocator(context, locator) { |
| 4202 | const loc = new Locator(locator) |
| 4203 | if (!loc.isRole()) return null |
| 4204 | |
| 4205 | const roleObj = loc.locator || {} |
| 4206 | const options = {} |
| 4207 | if (roleObj.text) options.name = roleObj.text |
| 4208 | if (roleObj.name) options.name = roleObj.name |
| 4209 | if (roleObj.exact !== undefined) options.exact = roleObj.exact |
| 4210 | |
| 4211 | return context.getByRole(roleObj.role, Object.keys(options).length > 0 ? options : undefined).all() |
| 4212 | } |
| 4213 | |
| 4214 | async function findByRole(context, locator) { |
| 4215 | if (!locator || !locator.role) return null |
no test coverage detected