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

Function findFields

lib/helper/Playwright.js:4408–4444  ·  view source on GitHub ↗
(locator, context = null)

Source from the content-addressed store, hash-verified

4406}
4407
4408async function findFields(locator, context = null) {
4409 let contextEl
4410 if (context) {
4411 const contextEls = await this._locate(context)
4412 assertElementExists(contextEls, context, 'Context element')
4413 contextEl = contextEls[0]
4414 }
4415
4416 const locateFn = contextEl
4417 ? loc => findElements.call(this, contextEl, loc)
4418 : loc => this._locate(loc)
4419
4420 const matcher = contextEl || (await this.page)
4421 const roleElements = await handleRoleLocator(matcher, locator)
4422 if (roleElements) return roleElements
4423
4424 const matchedLocator = new Locator(locator)
4425 if (!matchedLocator.isFuzzy()) {
4426 return locateFn(matchedLocator)
4427 }
4428 const literal = xpathLocator.literal(locator)
4429
4430 let els = await locateFn({ xpath: Locator.field.labelEquals(literal) })
4431 if (els.length) {
4432 return els
4433 }
4434
4435 els = await locateFn({ xpath: Locator.field.labelContains(literal) })
4436 if (els.length) {
4437 return els
4438 }
4439 els = await locateFn({ xpath: Locator.field.byName(literal) })
4440 if (els.length) {
4441 return els
4442 }
4443 return locateFn({ css: locator })
4444}
4445
4446async function proceedSelect(context, el, option) {
4447 const role = await el.getAttribute('role')

Callers

nothing calls this directly

Calls 4

isFuzzyMethod · 0.95
handleRoleLocatorFunction · 0.85
assertElementExistsFunction · 0.70
_locateMethod · 0.45

Tested by

no test coverage detected