MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / resolveAnchor

Function resolveAnchor

javascript/atoms/typescript/find-elements.ts:183–198  ·  view source on GitHub ↗
(selector: unknown)

Source from the content-addressed store, hash-verified

181 }
182
183 function resolveAnchor(selector: unknown): Element {
184 if (selector instanceof Element) {
185 return selector
186 }
187 if (typeof selector === 'function') {
188 return resolveAnchor((selector as () => unknown)())
189 }
190 if (selector && typeof selector === 'object') {
191 const found = findElements(selector as LocatorTarget)
192 if (!found.length) {
193 throw botError(NO_SUCH_ELEMENT, 'No element has been found by ' + JSON.stringify(selector))
194 }
195 return found[0]
196 }
197 throw botError(INVALID_ARGUMENT, 'Selector is of wrong type: ' + JSON.stringify(selector))
198 }
199
200 function makeProximityFilter(selector: unknown, test: (anchor: Rect, candidate: Rect) => boolean) {
201 return (candidate: Element): boolean => test(getClientRect(resolveAnchor(selector)), getClientRect(candidate))

Callers 3

makeProximityFilterFunction · 0.85
find-elements.tsFile · 0.85
relativeManyFunction · 0.85

Calls 1

botErrorFunction · 0.85

Tested by

no test coverage detected