fix(browser_utils): type via page.keyboard to survive NotebookLM re-r…#32
Open
almacd35712 wants to merge 1 commit into
Open
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
StealthUtils.human_typestores anElementHandleand types into itchar-by-char. NotebookLM's React UI re-mounts
textarea.query-box-inputon the first keystroke, detaching the handle and raising:
Every query fails after 1 character.
Repro
Fresh install →
auth_manager.py setup→ask_question.py --question "test" --notebook-url "https://notebooklm.google.com/notebook/<any-uuid>"— crashesafter "⏳ Typing question...".
Fix
Switch the per-char loop from
element.type(...)topage.keyboard.type(...).page.keyboardtargets whatever element has focus at the moment of eachkeystroke, 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.