fix(humanize): forward human_config in all chained methods, use evaluate args in handle pointer checks

- Add human_config=kwargs.get("human_config") to check/uncheck/select_option/press inner calls (sync+async+JS)
- Convert check_pointer_events_handle from f-string interpolation to evaluate args pattern (sync+async+JS)
This commit is contained in:
CloakHQ
2026-05-15 19:17:11 +02:00
parent 39f807f246
commit f4f6a3f8fd
5 changed files with 39 additions and 41 deletions
+11 -9
View File
@@ -205,6 +205,15 @@ _POINTER_EVENTS_LOCATOR_JS = """(expected, coords) => {
return { hit: false, reason: 'covered', covering: target.tagName || 'unknown' };
}"""
_POINTER_EVENTS_HANDLE_JS = """(expected, coords) => {
const target = document.elementFromPoint(coords.x, coords.y);
if (!target) return { hit: false, reason: 'no_element_at_point', covering: 'none' };
let node = target;
while (node) { if (node === expected) return { hit: true }; node = node.parentNode; }
if (expected.contains(target)) return { hit: true };
return { hit: false, reason: 'covered', covering: target.tagName || 'unknown' };
}"""
def check_pointer_events(
page: Any,
@@ -313,18 +322,11 @@ def check_pointer_events_handle(
deadline = time.monotonic() + timeout / 1000.0
attempt = 0
js = f"""(expected) => {{
const target = document.elementFromPoint({x}, {y});
if (!target) return {{ hit: false, reason: 'no_element_at_point', covering: 'none' }};
let node = target;
while (node) {{ if (node === expected) return {{ hit: true }}; node = node.parentNode; }}
if (expected.contains(target)) return {{ hit: true }};
return {{ hit: false, reason: 'covered', covering: target.tagName || 'unknown' }};
}}"""
coords = {"x": x, "y": y}
while True:
try:
result = el.evaluate(js)
result = el.evaluate(_POINTER_EVENTS_HANDLE_JS, coords)
except Exception:
result = None