MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / handleRoleLocator

Function handleRoleLocator

lib/helper/Playwright.js:4201–4212  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

4199 * Returns elements array if role locator, null otherwise
4200 */
4201async 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
4214async function findByRole(context, locator) {
4215 if (!locator || !locator.role) return null

Callers 4

grabTextFromMethod · 0.85
findElementsFunction · 0.85
findCheckableFunction · 0.85
findFieldsFunction · 0.85

Calls 1

isRoleMethod · 0.95

Tested by

no test coverage detected