MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / interactWithSimulatorViewport

Function interactWithSimulatorViewport

scripts/e2e-webrtc-reliability.mjs:1139–1172  ·  view source on GitHub ↗
(cdp, elapsedMs)

Source from the content-addressed store, hash-verified

1137}
1138
1139async function interactWithSimulatorViewport(cdp, elapsedMs) {
1140 const point = await evaluate(
1141 cdp,
1142 `
1143 (() => {
1144 const target = document.querySelector("canvas.stream-canvas") || document.querySelector(".device-screen");
1145 if (!target) return null;
1146 const rect = target.getBoundingClientRect();
1147 const x = rect.left + rect.width * (0.35 + ((Math.floor(${elapsedMs} / 5000) % 3) * 0.15));
1148 const y = rect.top + rect.height * 0.55;
1149 return { x, y };
1150 })()
1151 `,
1152 );
1153 if (!point) {
1154 return;
1155 }
1156 await cdp.send("Input.dispatchMouseEvent", {
1157 button: "left",
1158 buttons: 1,
1159 clickCount: 1,
1160 type: "mousePressed",
1161 x: point.x,
1162 y: point.y,
1163 });
1164 await cdp.send("Input.dispatchMouseEvent", {
1165 button: "left",
1166 buttons: 0,
1167 clickCount: 1,
1168 type: "mouseReleased",
1169 x: point.x,
1170 y: point.y,
1171 });
1172}

Callers 1

Calls 2

evaluateFunction · 0.85
sendMethod · 0.65

Tested by

no test coverage detected