MCPcopy Index your code
hub / github.com/callstack/agent-device / waitForSelector

Function waitForSelector

src/commands/interaction/runtime/selector-read.ts:459–478  ·  view source on GitHub ↗
(
  runtime: AgentDeviceRuntime,
  options: WaitCommandOptions,
  selectorExpression: string,
  timeoutMs: number | null | undefined,
)

Source from the content-addressed store, hash-verified

457}
458
459async function waitForSelector(
460 runtime: AgentDeviceRuntime,
461 options: WaitCommandOptions,
462 selectorExpression: string,
463 timeoutMs: number | null | undefined,
464): Promise<WaitCommandResult> {
465 const timeout = timeoutMs ?? DEFAULT_TIMEOUT_MS;
466 const start = now(runtime);
467 const chain = parseSelectorChain(selectorExpression);
468 while (now(runtime) - start < timeout) {
469 const capture = await captureSelectorSnapshot(runtime, options, { updateSession: true });
470 const match = findSelectorChainMatch(capture.snapshot.nodes, chain, {
471 platform: runtime.backend.platform,
472 });
473 if (match)
474 return { kind: 'selector', selector: match.selector.raw, waitedMs: now(runtime) - start };
475 await sleep(runtime, POLL_INTERVAL_MS);
476 }
477 throw new AppError('COMMAND_FAILED', `wait timed out for selector: ${selectorExpression}`);
478}
479
480async function waitForText(
481 runtime: AgentDeviceRuntime,

Callers 1

waitCommandFunction · 0.85

Calls 5

nowFunction · 0.90
parseSelectorChainFunction · 0.90
captureSelectorSnapshotFunction · 0.90
findSelectorChainMatchFunction · 0.90
sleepFunction · 0.90

Tested by

no test coverage detected