Skip to content

[Bug] Extension attach to existing Edge tab leaves main world unusable until first Playwright navigation #1480

@escape0707

Description

@escape0707

Summary

When I attach to an already-open Edge tab via playwright-cli open --extension and select that tab in Edge, the session partially works:

  • tab-list, snapshot, console, and network work
  • eval hangs
  • input-style commands like hover hang

If I immediately run goto <current-url> after attach, eval and hover start working on that same session.

This looks like the selected existing tab is attached with a usable utility world, but not a usable main world, until the first Playwright-driven navigation.

Environment

  • @playwright/cli: 1.59.0-alpha-1771104257000
  • Node: v25.8.1
  • OS: Arch Linux on WSL2
  • Browser: Microsoft Edge on Windows, launched from WSL with:
    • PLAYWRIGHT_MCP_EXECUTABLE_PATH="/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"

CLI repro

  1. Run:
export PLAYWRIGHT_MCP_EXECUTABLE_PATH="/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
playwright-cli open --extension --browser=msedge
  1. In Edge, choose an already-open regular web page tab to attach to.
  2. Run:
playwright-cli tab-list
playwright-cli snapshot
playwright-cli eval "() => document.title"
playwright-cli hover <some-ref-from-snapshot>

Actual behavior

  • tab-list works
  • snapshot works
  • eval hangs / times out
  • hover hangs

Expected behavior

After selecting an existing tab, eval and DOM interaction commands should work without needing a forced navigation first.

Workaround

If I run:

playwright-cli goto <the-current-tab-url>

then both of these start working:

playwright-cli eval "() => document.title"
playwright-cli hover <some-ref-from-snapshot>

This reloads the page, so it is only a partial workaround.

Lower-level repro

Using Playwright's internal extension attach path directly, I can reproduce the same split:

  • page.title() works immediately after attach
  • page.evaluate(() => document.title) times out immediately after attach
  • after await page.goto(page.url()), page.evaluate(() => document.title) works

I also found that direct Playwright locator.hover() can succeed before the navigation, which suggests there may be two related problems:

  1. The attached existing tab does not have a usable main-world execution context until first Playwright navigation.
  2. playwright-cli input-style commands appear to hang because their post-action completion path depends on page.evaluate(...).

Notes

Related but not exact matches:

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