element from point potential fix
Build and Push Docker Images / build-and-push (push) Successful in 1m22s
Build and Push Docker Images / build-and-push (push) Successful in 1m22s
This commit is contained in:
@@ -282,29 +282,37 @@ async def interactions_service(
|
|||||||
elif x is not None and y is not None:
|
elif x is not None and y is not None:
|
||||||
if action == "click":
|
if action == "click":
|
||||||
# Use DOM elementFromPoint so React/SPA components receive real click events.
|
# Use DOM elementFromPoint so React/SPA components receive real click events.
|
||||||
handle = await page.evaluate_handle(
|
|
||||||
"(cx, cy) => document.elementFromPoint(cx, cy)",
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
await handle.click()
|
handle = await page.evaluate_handle(
|
||||||
|
f"document.elementFromPoint({x}, {y})"
|
||||||
|
)
|
||||||
|
element = handle.as_element()
|
||||||
|
if element is None:
|
||||||
|
raise ValueError(f"No element found at coordinates ({x}, {y})")
|
||||||
|
await element.click()
|
||||||
finally:
|
finally:
|
||||||
await handle.dispose()
|
try:
|
||||||
|
await handle.dispose()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
elif action == "type":
|
elif action == "type":
|
||||||
if text is None:
|
if text is None:
|
||||||
raise ValueError("Type interaction must contain text")
|
raise ValueError("Type interaction must contain text")
|
||||||
# Focus the element at the given coordinates, then type.
|
# Focus the element at the given coordinates, then type.
|
||||||
handle = await page.evaluate_handle(
|
|
||||||
"(cx, cy) => document.elementFromPoint(cx, cy)",
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
await handle.click()
|
handle = await page.evaluate_handle(
|
||||||
|
f"document.elementFromPoint({x}, {y})"
|
||||||
|
)
|
||||||
|
element = handle.as_element()
|
||||||
|
if element is None:
|
||||||
|
raise ValueError(f"No element found at coordinates ({x}, {y})")
|
||||||
|
await element.click()
|
||||||
finally:
|
finally:
|
||||||
await handle.dispose()
|
try:
|
||||||
|
await handle.dispose()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
await page.keyboard.type(text)
|
await page.keyboard.type(text)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user