MCPcopy
hub / github.com/codeceptjs/CodeceptJS / filterFieldsByValue

Function filterFieldsByValue

lib/helper/Puppeteer.js:3378–3396  ·  view source on GitHub ↗
(elements, value, onlySelected)

Source from the content-addressed store, hash-verified

3376}
3377
3378async function filterFieldsByValue(elements, value, onlySelected) {
3379 const matches = []
3380 for (const element of elements) {
3381 let val = await element.getProperty('value').then(el => el.jsonValue())
3382
3383 if (val === undefined || val === null) {
3384 val = await element.evaluate(el => el.textContent || el.innerText)
3385 }
3386
3387 let isSelected = true
3388 if (onlySelected) {
3389 isSelected = await elementSelected(element)
3390 }
3391 if ((value == null || (val && val.indexOf(value) > -1)) && isSelected) {
3392 matches.push(element)
3393 }
3394 }
3395 return matches
3396}
3397
3398async function filterFieldsBySelectionState(elements, state) {
3399 const matches = []

Callers 1

proceedSeeInFieldFunction · 0.70

Calls 4

getPropertyMethod · 0.80
evaluateMethod · 0.80
pushMethod · 0.80
elementSelectedFunction · 0.70

Tested by

no test coverage detected