Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

test(e2e): add humanType/humanClick test scenario

Bosche1e47ebecc3f
diff --git a/tests/e2e/fixtures/human-type.html b/tests/e2e/fixtures/human-type.html
new file mode 100644
index 00000000..bbf32123
--- /dev/null
+++ b/tests/e2e/fixtures/human-type.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head><title>Human Type Test</title></head>
+<body>
+ <h1>Human Type Test</h1>
+ <form>
+ <label for="email">Email</label>
+ <input type="text" id="email" name="email" placeholder="Enter email">
+ <label for="name">Name</label>
+ <input type="text" id="name" name="name" placeholder="Enter name">
+ </form>
+ <script>
+ // Track input events to verify human-like typing triggers them
+ document.querySelectorAll('input').forEach(input => {
+ input.addEventListener('input', (e) => {
+ e.target.dataset.inputEvents = (parseInt(e.target.dataset.inputEvents || '0') + 1).toString();
+ });
+ });
+ </script>
+</body>
+</html>
diff --git a/tests/e2e/scenarios/23-human-type.sh b/tests/e2e/scenarios/23-human-type.sh
new file mode 100755
index 00000000..7987ad04
--- /dev/null
+++ b/tests/e2e/scenarios/23-human-type.sh
@@ -0,0 +1,94 @@
+#!/bin/bash
+# 23-human-type.sh — humanType and humanClick actions
+
+source "$(dirname "$0")/common.sh"
+
+# ─────────────────────────────────────────────────────────────────
+start_test "humanClick: click input by ref"
+
+pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/human-type.html\"}"
+sleep 1
+
+# Get snapshot to populate ref cache
+pt_get /snapshot
+assert_ok "snapshot loaded"
+
+# Find the email input ref
+EMAIL_REF=$(echo "$RESULT" | jq -r '[.nodes[] | select(.role=="textbox" and .name=="Email")][0].ref')
+if [ -z "$EMAIL_REF" ] || [ "$EMAIL_REF" = "null" ]; then
+ echo -e " ${RED}✗${NC} could not find Email textbox ref"
+ ((ASSERTIONS_FAILED++)) || true
+else
+ echo -e " ${GREEN}✓${NC} found Email ref: $EMAIL_REF"
+ ((ASSERTIONS_PASSED++)) || true
+
+ # humanClick on the input
+ pt_post /action -d "{\"kind\":\"humanClick\",\"ref\":\"$EMAIL_REF\"}"
+ assert_ok "humanClick on email input"
+fi
+
+end_test
+
+# ─────────────────────────────────────────────────────────────────
+start_test "humanType: type into input by ref"
+
+# Re-fetch snapshot for fresh refs
+pt_get /snapshot
+EMAIL_REF=$(echo "$RESULT" | jq -r '[.nodes[] | select(.role=="textbox" and .name=="Email")][0].ref')
+
+if [ -z "$EMAIL_REF" ] || [ "$EMAIL_REF" = "null" ]; then
+ echo -e " ${RED}✗${NC} could not find Email textbox ref"
+ ((ASSERTIONS_FAILED++)) || true
+else
+ # humanType into the email field
+ pt_post /action -d "{\"kind\":\"humanType\",\"ref\":\"$EMAIL_REF\",\"text\":\"[email protected]\"}"
+ assert_ok "humanType into email input"
+
+ # Verify the text was typed
+ pt_get /snapshot
+ TYPED_VALUE=$(echo "$RESULT" | jq -r '[.nodes[] | select(.role=="textbox" and .name=="Email")][0].value // empty')
+ if echo "$TYPED_VALUE" | grep -q "[email protected]"; then
+ echo -e " ${GREEN}✓${NC} value is: $TYPED_VALUE"
+ ((ASSERTIONS_PASSED++)) || true
+ else
+ echo -e " ${RED}✗${NC} expected '[email protected]', got: '$TYPED_VALUE'"
+ ((ASSERTIONS_FAILED++)) || true
+ fi
+fi
+
+end_test
+
+# ─────────────────────────────────────────────────────────────────
+start_test "humanType: type into second input by ref"
+
+# Get fresh snapshot
+pt_get /snapshot
+NAME_REF=$(echo "$RESULT" | jq -r '[.nodes[] | select(.role=="textbox" and .name=="Name")][0].ref')
+
+if [ -z "$NAME_REF" ] || [ "$NAME_REF" = "null" ]; then
+ echo -e " ${RED}✗${NC} could not find Name textbox ref"
+ ((ASSERTIONS_FAILED++)) || true
+else
+ pt_post /action -d "{\"kind\":\"humanType\",\"ref\":\"$NAME_REF\",\"text\":\"John Doe\"}"
+ assert_ok "humanType into name input"
+
+ pt_get /snapshot
+ TYPED_VALUE=$(echo "$RESULT" | jq -r '[.nodes[] | select(.role=="textbox" and .name=="Name")][0].value // empty')
+ if echo "$TYPED_VALUE" | grep -q "John Doe"; then
+ echo -e " ${GREEN}✓${NC} value is: $TYPED_VALUE"
+ ((ASSERTIONS_PASSED++)) || true
+ else
+ echo -e " ${RED}✗${NC} expected 'John Doe', got: '$TYPED_VALUE'"
+ ((ASSERTIONS_FAILED++)) || true
+ fi
+fi
+
+end_test
+
+# ─────────────────────────────────────────────────────────────────
+start_test "humanType: type with CSS selector"
+
+pt_post /action -d "{\"kind\":\"humanType\",\"selector\":\"#name\",\"text\":\" Jr.\"}"
+assert_ok "humanType with CSS selector"
+
+end_test