Skip to content

fix(browser_utils): type via page.keyboard to survive NotebookLM re-r…#32

Open
almacd35712 wants to merge 1 commit into
PleasePrompto:masterfrom
almacd35712:fix/stale-element-handle-in-human-type
Open

fix(browser_utils): type via page.keyboard to survive NotebookLM re-r…#32
almacd35712 wants to merge 1 commit into
PleasePrompto:masterfrom
almacd35712:fix/stale-element-handle-in-human-type

Conversation

@almacd35712
Copy link
Copy Markdown

Problem

StealthUtils.human_type stores an ElementHandle and types into it
char-by-char. NotebookLM's React UI re-mounts textarea.query-box-input
on the first keystroke, detaching the handle and raising:

  ElementHandle.type: Element is not attached to the DOM
  Call log: elementHandle.type("m")

Every query fails after 1 character.

Repro

Fresh install → auth_manager.py setupask_question.py --question "test" --notebook-url "https://notebooklm.google.com/notebook/<any-uuid>" — crashes
after "⏳ Typing question...".

Fix

Switch the per-char loop from element.type(...) to page.keyboard.type(...).
page.keyboard targets whatever element has focus at the moment of each
keystroke, so it survives React re-renders. Human-cadence (delay + 5%
micro-pause) unchanged.

Testing

Windows 11, Chrome 131, patchright 1.55.2. Before: 100% failure. After: full
query-answer round-trip against a 19-source notebook completes in ~2min with
grounded, cited answer. Verified across 3 consecutive queries.

…enders

StealthUtils.human_type captures an ElementHandle once and types into it
char-by-char. Against the current NotebookLM UI, the `textarea.query-box-input`
is re-mounted by React on the first keystroke, which detaches the handle
and raises:

  patchright._impl._errors.Error: ElementHandle.type: Element is not
  attached to the DOM

Switching to `page.keyboard.type` (which targets the currently-focused
element at the moment of each keystroke) survives the re-render without
losing the human-like per-character delay and occasional pause.

Repro: install the skill on a fresh env, auth, run ask_question.py against
any notebook. The typing loop fails after 1 character.

Tested locally (Windows 11, Chrome 131, patchright 1.55.2): fix lands the
question intact and completes the full query-and-answer flow. The rest of
the stealth loop (click-to-focus, per-char delay, random 5% micro-pause)
is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants