Skip to content

Opening Print PDF Modal on a tab with stagehand causes CDPSession.send: Target page, context or browser has been closed #248

@aditya-silna

Description

@aditya-silna

Before submitting an issue, please:

Environment Information

Please provide the following information to help us reproduce and resolve your issue:

Stagehand:

  • Language/SDK: [TypeScript, Python, MCP…]
  • Stagehand version: [e.g., 1.0.0]
    Python version 0.5.6

AI Provider:

  • Provider: [e.g., OpenAI, Anthropic, Azure OpenAI]
  • Model: [e.g., gpt-4o, claude-3-7-sonnet-latest]

N/A

Issue Description

Using `act()` to click a button that opens a PDF modal is not handled by Stagehand's `Page` proxy, and doing CDP operations `stagehand.page.send_cdp()` then causes `CDPSession.send: Target page, context or browser has been closed`

Steps to Reproduce

  1. act() on a button that calls JS to open window.print()
  2. do `stagehand.page.send_cdp("Target.getTargetInfo")

### Error Messages / Log trace

TargetClosedError
Level: Error
CDPSession.send: Target page, context or browser has been closed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions