midscene
midscene copied to clipboard
[Bug]: Web integration `longPress` action caps to 600ms
Version
Apple M4
Chrome
"@midscene/web": "^1.8.5"
Details
in report:
model used longPress as indicated:
<log>Long-pressing the "Interact here" area for 6 seconds</log>
<action-type>LongPress</action-type>
<action-param-json>
{
"locate": {
"prompt": "the 'Interact here' text area",
"bbox": [
455,
896,
543,
932
]
},
"duration": 6000
}
</action-param-json>
but in log: [2026-05-26T15:48:24.589+08:00] mouse longPress at 638, 702 for 600ms
which indicates that the longPress lasts for only 600ms, and in code I found:
async longPress(x: number, y: number, duration?: number) {
duration = duration || 500;
const LONG_PRESS_THRESHOLD = 600;
const MIN_PRESS_THRESHOLD = 300;
if (duration > LONG_PRESS_THRESHOLD) {
duration = LONG_PRESS_THRESHOLD;
}
if (duration < MIN_PRESS_THRESHOLD) {
duration = MIN_PRESS_THRESHOLD;
}
debugPage(`mouse longPress at ${x}, ${y} for ${duration}ms`);
if (this.interfaceType === 'puppeteer') {
const page = this.underlyingPage as PuppeteerPage;
await page.mouse.move(x, y);
await page.mouse.down({ button: 'left' });
await new Promise((res) => setTimeout(res, duration));
await page.mouse.up({ button: 'left' });
} else if (this.interfaceType === 'playwright') {
const page = this.underlyingPage as PlaywrightPage;
await page.mouse.move(x, y);
await page.mouse.down({ button: 'left' });
await page.waitForTimeout(duration);
await page.mouse.up({ button: 'left' });
}
}
there is a cap over duration of longPress. May I ask why?
Reproduce link
https://github.com/o0O96O0o/midscene-example/tree/main/playwright-longPress
Reproduce Steps
npm installnpm run test
second assertion failed as longPress duration not satisfy our requirement