skopix 2.0.18 → 2.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/commands/agent.js +18 -7
- package/package.json +1 -1
package/cli/commands/agent.js
CHANGED
|
@@ -361,7 +361,7 @@ export async function agentCommand(options) {
|
|
|
361
361
|
await page.waitForTimeout(800);
|
|
362
362
|
|
|
363
363
|
} else if (step.action === 'click') {
|
|
364
|
-
await page.waitForTimeout(
|
|
364
|
+
await page.waitForTimeout(100);
|
|
365
365
|
let clicked = false;
|
|
366
366
|
const selectors = [step.stableSelector, step.selector].filter(Boolean).map(sanitiseSelector);
|
|
367
367
|
if (!clicked && (step.elementX || step.clickX)) {
|
|
@@ -373,16 +373,15 @@ export async function agentCommand(options) {
|
|
|
373
373
|
if (count > 1) {
|
|
374
374
|
let bi = 0, bd = Infinity;
|
|
375
375
|
for (let i = 0; i < count; i++) { try { const box = await page.locator(s).nth(i).boundingBox({ timeout: 2000 }); if (!box) continue; const d = Math.sqrt(Math.pow(box.x + box.width / 2 - tx, 2) + Math.pow(box.y + box.height / 2 - ty, 2)); if (d < bd) { bd = d; bi = i; } } catch {} }
|
|
376
|
-
await page.locator(s).nth(bi).scrollIntoViewIfNeeded({ timeout: 3000 }).catch(() => {});
|
|
377
376
|
await page.locator(s).nth(bi).click({ timeout: 5000 }); clicked = true;
|
|
378
377
|
} else if (count === 1) {
|
|
379
|
-
await page.locator(s).first().scrollIntoViewIfNeeded({ timeout: 3000 }).catch(() => {});
|
|
380
378
|
await page.locator(s).first().click({ timeout: 5000 }); clicked = true;
|
|
381
379
|
}
|
|
382
380
|
} catch {}
|
|
383
381
|
}
|
|
384
382
|
}
|
|
385
|
-
if (!clicked) { for (const s of selectors) { if (clicked) break; try { await page.locator(s).first().
|
|
383
|
+
if (!clicked) { for (const s of selectors) { if (clicked) break; try { await page.locator(s).first().click({ timeout: 5000 }); clicked = true; } catch {} } }
|
|
384
|
+
if (!clicked) { for (const s of selectors) { if (clicked) break; try { await page.locator(s).first().scrollIntoViewIfNeeded({ timeout: 2000 }).catch(() => {}); await page.locator(s).first().click({ timeout: 5000 }); clicked = true; } catch {} } }
|
|
386
385
|
if (!clicked) { for (const s of selectors) { if (clicked) break; try { await page.locator(s).first().click({ force: true, timeout: 5000 }); clicked = true; } catch {} } }
|
|
387
386
|
if (!clicked) {
|
|
388
387
|
// Last resort — JS dispatch for framework-managed elements
|
|
@@ -402,11 +401,23 @@ export async function agentCommand(options) {
|
|
|
402
401
|
|
|
403
402
|
// Special handling for Bootstrap dropdowns — wait for menu to appear
|
|
404
403
|
try {
|
|
405
|
-
const el =
|
|
404
|
+
const el = page.locator(selectors[0]).first();
|
|
406
405
|
const isDropdown = await el.evaluate(e => e.hasAttribute('data-toggle') && e.getAttribute('data-toggle') === 'dropdown').catch(() => false);
|
|
407
406
|
if (isDropdown) {
|
|
408
|
-
|
|
409
|
-
await page.
|
|
407
|
+
// Try jQuery dropdown toggle first (Bootstrap 3)
|
|
408
|
+
const toggled = await page.evaluate((sel) => {
|
|
409
|
+
try {
|
|
410
|
+
const el = document.querySelector(sel);
|
|
411
|
+
if (el && window.$) { window.$(el).dropdown('toggle'); return true; }
|
|
412
|
+
} catch {}
|
|
413
|
+
return false;
|
|
414
|
+
}, selectors[0]).catch(() => false);
|
|
415
|
+
if (!toggled) {
|
|
416
|
+
// Fallback: dispatch click on the element
|
|
417
|
+
await el.evaluate(e => e.click());
|
|
418
|
+
}
|
|
419
|
+
await page.waitForSelector('.dropdown-menu', { state: 'visible', timeout: 3000 }).catch(() => {});
|
|
420
|
+
await page.waitForTimeout(400);
|
|
410
421
|
}
|
|
411
422
|
} catch {}
|
|
412
423
|
|
package/package.json
CHANGED