(locator, context = null)
| 3244 | } |
| 3245 | |
| 3246 | async function findFields(locator, context = null) { |
| 3247 | let contextEl |
| 3248 | if (context) { |
| 3249 | const contextPage = await this.context |
| 3250 | const contextEls = await findElements.call(this, contextPage, context) |
| 3251 | assertElementExists(contextEls, context, 'Context element') |
| 3252 | contextEl = contextEls[0] |
| 3253 | } |
| 3254 | |
| 3255 | const locateFn = contextEl |
| 3256 | ? loc => findElements.call(this, contextEl, loc) |
| 3257 | : loc => this._locate(loc) |
| 3258 | |
| 3259 | const matchedLocator = new Locator(locator) |
| 3260 | if (!matchedLocator.isFuzzy()) { |
| 3261 | return locateFn(matchedLocator) |
| 3262 | } |
| 3263 | const literal = xpathLocator.literal(matchedLocator.value) |
| 3264 | |
| 3265 | let els = await locateFn({ xpath: Locator.field.labelEquals(literal) }) |
| 3266 | if (els.length) { |
| 3267 | return els |
| 3268 | } |
| 3269 | |
| 3270 | els = await locateFn({ xpath: Locator.field.labelContains(literal) }) |
| 3271 | if (els.length) { |
| 3272 | return els |
| 3273 | } |
| 3274 | els = await locateFn({ xpath: Locator.field.byName(literal) }) |
| 3275 | if (els.length) { |
| 3276 | return els |
| 3277 | } |
| 3278 | |
| 3279 | // Try ARIA selector for accessible name |
| 3280 | if (!contextEl) { |
| 3281 | try { |
| 3282 | const page = await this.context |
| 3283 | els = await page.$$(`::-p-aria(${matchedLocator.value})`) |
| 3284 | if (els.length) return els |
| 3285 | } catch (err) { |
| 3286 | // ARIA selector not supported or failed |
| 3287 | } |
| 3288 | } |
| 3289 | |
| 3290 | return locateFn({ css: matchedLocator.value }) |
| 3291 | } |
| 3292 | |
| 3293 | async function proceedDragAndDrop(sourceLocator, destinationLocator) { |
| 3294 | const src = await this._locateElement(sourceLocator) |
nothing calls this directly
no test coverage detected