Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions scripts/browser_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,15 @@ def human_type(page: Page, selector: str, text: str, wpm_min: int = 320, wpm_max

# Click to focus
element.click()

# Type

# Type via page-level keyboard. Typing on the stored ElementHandle
# fails against NotebookLM's current UI because the textarea is
# re-rendered on first keystroke (React re-mount), which detaches
# the handle and raises `ElementHandle.type: Element is not attached
# to the DOM`. page.keyboard.type targets whatever element has
# focus at the moment of the keystroke, so it survives re-renders.
for char in text:
element.type(char, delay=random.uniform(25, 75))
page.keyboard.type(char, delay=random.uniform(25, 75))
if random.random() < 0.05:
time.sleep(random.uniform(0.15, 0.4))

Expand Down