storyboard-bridge 0.9.21 → 0.9.22
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/cdp_flow.py +25 -10
- package/package.json +1 -1
package/cdp_flow.py
CHANGED
|
@@ -529,27 +529,42 @@ def main():
|
|
|
529
529
|
step_vars[var] = ""
|
|
530
530
|
elif kind == "drag":
|
|
531
531
|
xpath, direction, steps_count, duration = val[0], val[1], int(val[2]), float(val[3])
|
|
532
|
-
#
|
|
533
|
-
|
|
532
|
+
# Drag implementation: find element, emit mousedown, mousemove sequence, mouseup
|
|
533
|
+
start_x, start_y = page.eval(f"""
|
|
534
534
|
(function() {{
|
|
535
535
|
const el = document.evaluate({json.dumps(xpath)}, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
|
536
536
|
if (!el) return null;
|
|
537
537
|
const rect = el.getBoundingClientRect();
|
|
538
|
-
return
|
|
538
|
+
return [rect.left + rect.width/2, rect.top + rect.height/2];
|
|
539
539
|
}})()
|
|
540
540
|
""")
|
|
541
|
-
if
|
|
542
|
-
start_x, start_y = int(
|
|
541
|
+
if start_x is not None:
|
|
542
|
+
start_x, start_y = int(start_x), int(start_y)
|
|
543
543
|
end_x = start_x + (200 if direction == "right" else -200)
|
|
544
544
|
step_duration = duration / steps_count
|
|
545
|
+
page.eval(f"""
|
|
546
|
+
(function() {{
|
|
547
|
+
const el = document.evaluate({json.dumps(xpath)}, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
|
548
|
+
const ev = new PointerEvent('pointerdown', {{ clientX: {start_x}, clientY: {start_y}, bubbles: true, cancelable: true }});
|
|
549
|
+
el.dispatchEvent(ev);
|
|
550
|
+
}})()
|
|
551
|
+
""")
|
|
545
552
|
for step_i in range(steps_count):
|
|
546
553
|
x = start_x + (end_x - start_x) * (step_i / steps_count)
|
|
547
|
-
page.
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
})
|
|
554
|
+
page.eval(f"""
|
|
555
|
+
(function() {{
|
|
556
|
+
const ev = new PointerEvent('pointermove', {{ clientX: {int(x)}, clientY: {start_y}, bubbles: true, cancelable: true }});
|
|
557
|
+
document.elementFromPoint({int(x)}, {start_y})?.dispatchEvent(ev);
|
|
558
|
+
}})()
|
|
559
|
+
""")
|
|
552
560
|
time.sleep(step_duration)
|
|
561
|
+
page.eval(f"""
|
|
562
|
+
(function() {{
|
|
563
|
+
const el = document.elementFromPoint({end_x}, {start_y});
|
|
564
|
+
const ev = new PointerEvent('pointerup', {{ clientX: {end_x}, clientY: {start_y}, bubbles: true, cancelable: true }});
|
|
565
|
+
el?.dispatchEvent(ev);
|
|
566
|
+
}})()
|
|
567
|
+
""")
|
|
553
568
|
print(f" dragged {direction}")
|
|
554
569
|
time.sleep(delay)
|
|
555
570
|
print("flow complete")
|
package/package.json
CHANGED