MCPcopy Create free account
hub / github.com/InverseUI/InverseUI-Recorder / waitForElement

Method waitForElement

util/dom_utils.js:603–632  ·  view source on GitHub ↗
(xpath, timeout = 10000)

Source from the content-addressed store, hash-verified

601
602 // Wait for element to appear
603 async waitForElement(xpath, timeout = 10000) {
604 const startTime = Date.now();
605
606 return new Promise((resolve, reject) => {
607 const checkInterval = 100; // Check every 100ms
608
609 const check = () => {
610 const element = this.findElement(xpath);
611
612 if (element && this.isElementVisible(element)) {
613 resolve({
614 success: true,
615 xpath: xpath,
616 waitTime: Date.now() - startTime,
617 element: {
618 tagName: element.tagName,
619 id: element.id,
620 className: element.className
621 }
622 });
623 } else if (Date.now() - startTime > timeout) {
624 reject(new Error(`Timeout waiting for element: ${xpath}`));
625 } else {
626 setTimeout(check, checkInterval);
627 }
628 };
629
630 check();
631 });
632 }
633}

Callers 1

initMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected