MCPcopy
hub / github.com/VibiumDev/vibium / find

Method find

clients/javascript/src/page.ts:624–653  ·  view source on GitHub ↗

Find an element by CSS selector or semantic options. Waits for element to exist.

(selector: string | SelectorOptions, options?: FindOptions)

Source from the content-addressed store, hash-verified

622
623 /** Find an element by CSS selector or semantic options. Waits for element to exist. */
624 find(selector: string | SelectorOptions, options?: FindOptions): FluentElement {
625 const promise = (async () => {
626 const params: Record<string, unknown> = {
627 context: this.contextId,
628 timeout: options?.timeout,
629 };
630
631 if (typeof selector === 'string') {
632 debug('page.find', { selector, timeout: options?.timeout });
633 params.selector = selector;
634 } else {
635 debug('page.find', { ...selector, timeout: options?.timeout });
636 Object.assign(params, selector);
637 if (selector.timeout && !options?.timeout) params.timeout = selector.timeout;
638 }
639
640 const result = await this.client.send<VibiumFindResult>('vibium:page.find', params);
641
642 const info: ElementInfo = {
643 tag: result.tag,
644 text: result.text,
645 box: result.box,
646 };
647
648 const selectorStr = typeof selector === 'string' ? selector : '';
649 const selectorParams = typeof selector === 'string' ? { selector } : { ...selector };
650 return new Element(this.client, this.contextId, selectorStr, info, undefined, selectorParams);
651 })();
652 return fluent(promise);
653 }
654
655 /** Find all elements matching a CSS selector or semantic options. Waits for at least one. */
656 async findAll(selector: string | SelectorOptions, options?: FindOptions): Promise<Element[]> {

Callers 15

compare-traces.mjsFile · 0.45
saucedemo-e2e.mjsFile · 0.45
selectors.test.jsFile · 0.45
input-eval.test.jsFile · 0.45
recording.test.jsFile · 0.45
a11y.test.jsFile · 0.45

Calls 2

debugFunction · 0.90
fluentFunction · 0.90

Tested by 15

test_role_linkFunction · 0.36
test_role_headingFunction · 0.36
test_role_explicitFunction · 0.36
test_role_chainFunction · 0.36
test_label_linkFunction · 0.36
test_label_aria_labelFunction · 0.36
test_label_forFunction · 0.36
test_label_chainFunction · 0.36
test_click_navigatesFunction · 0.36
test_dblclickFunction · 0.36
test_fillFunction · 0.36