MCPcopy Create free account
hub / github.com/ACM-VIT/conclave / waitFor

Function waitFor

scripts/debug-video-effects-headless.mjs:828–862  ·  view source on GitHub ↗
(cdp, label, expression, timeout = timeoutMs)

Source from the content-addressed store, hash-verified

826 probe: await collectProbe(cdp),
827 });
828 throw new Error(`Element not found or disabled: ${testId}`);
829};
830
831const clickSelector = async (cdp, selector, timeout = 5000) => {
832 const started = Date.now();
833 while (Date.now() - started < timeout) {
834 const ok = await evalValue(
835 cdp,
836 `(() => {
837 const element = document.querySelector(${JSON.stringify(selector)});
838 if (!(element instanceof HTMLElement)) return false;
839 if (element instanceof HTMLButtonElement && element.disabled) return false;
840 element.click();
841 return true;
842 })()`,
843 ).catch(() => false);
844 if (ok) return;
845 await sleep(150);
846 }
847 emit("click_selector_failed", {
848 selector,
849 elapsedMs: Date.now() - started,
850 probe: await collectProbe(cdp),
851 });
852 throw new Error(`Element not found or disabled: ${selector}`);
853};
854
855const turnCameraOnIfNeeded = async (cdp, label) => {
856 const cameraState = await waitFor(
857 cdp,
858 `${label} camera state`,
859 `(() => {
860 const debug = window.__conclaveGetMeetVideoDebug?.();
861 const liveVideoFromDebug =
862 debug?.rawTrack?.readyState === "live" ||
863 debug?.localStream?.videoTracks?.some?.((track) => track.readyState === "live") ||
864 false;
865 const liveVideoFromElement = Array.from(document.querySelectorAll("video")).some((video) => {

Calls 7

collectProbeFunction · 0.85
isGenericErrorPageProbeFunction · 0.85
nowMethod · 0.80
evalValueFunction · 0.70
emitFunction · 0.70
sleepFunction · 0.70

Tested by

no test coverage detected