mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-10 16:14:54 +03:00
fix(web-test): clickElement retries when modal form is still loading
After F4/Enter that opens a modal, clickElement could fail because detectFormScript found the parent form before the modal appeared. Now retries up to 2s, re-detecting the form each time. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1363,11 +1363,25 @@ export async function clickElement(text, { dblclick } = {}) {
|
||||
// No match in popup — fall through to form elements
|
||||
}
|
||||
|
||||
const formNum = await page.evaluate(detectFormScript());
|
||||
let formNum = await page.evaluate(detectFormScript());
|
||||
if (formNum === null) throw new Error(`clickElement: no form found`);
|
||||
|
||||
// Find the target element ID
|
||||
const target = await page.evaluate(findClickTargetScript(formNum, text));
|
||||
let target = await page.evaluate(findClickTargetScript(formNum, text));
|
||||
|
||||
// Retry: if not found, a modal form may still be loading (e.g. after F4).
|
||||
// Wait up to 2s for a new form to appear and re-detect.
|
||||
if (target?.error) {
|
||||
for (let retry = 0; retry < 4; retry++) {
|
||||
await page.waitForTimeout(500);
|
||||
const newForm = await page.evaluate(detectFormScript());
|
||||
if (newForm !== null && newForm !== formNum) {
|
||||
formNum = newForm;
|
||||
target = await page.evaluate(findClickTargetScript(formNum, text));
|
||||
if (!target?.error) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (target?.error) throw new Error(`clickElement: "${text}" not found. Available: ${target.available?.join(', ') || 'none'}`);
|
||||
|
||||
// Grid row targets — use coordinate click (single or double)
|
||||
|
||||
Reference in New Issue
Block a user