Skip to content

snapshot command displays incorrect Page URL/Title when using multi-tab feature #257

@cephalin

Description

@cephalin

Bug Description

When using the multi-tab feature with tab-select, the snapshot command outputs incorrect metadata in the "Page" section. It displays tab 0's URL and Title even when a different tab is selected as current.

Steps to Reproduce

  1. Start a session and open a page:

    playwright-cli -s=test open --headed "https://portal.azure.com"
  2. Create a new tab and navigate to a different site:

    playwright-cli -s=test tab-new "https://example.com"
  3. Verify current tab:

    playwright-cli -s=test tab-list

    Output shows tab 1 is current:

    - 0: [portal.azure.com]
    - 1: (current) [Example Domain]
    
  4. Take snapshot:

    playwright-cli -s=test snapshot

Expected Behavior

The snapshot output should show:

### Page
- Page URL: https://example.com/
- Page Title: Example Domain

Actual Behavior

The snapshot output incorrectly shows tab 0's information:

### Page
- Page URL: https://portal.azure.com/
- Page Title: Microsoft Azure

However:

  • The snapshot YAML content itself IS correct (shows example.com page structure)
  • The eval command confirms the correct URL/title
  • The bug is only in the snapshot metadata display

Impact

This creates confusion when testing multi-tab workflows, as agents/users see conflicting information between the "Page" metadata and the actual snapshot content.

Environment

  • playwright-cli version: Latest (installed via npx @playwright/cli@latest)
  • OS: macOS
  • Browser: Chrome (headed mode)

Workaround

Use eval to verify the actual page:

playwright-cli -s=test eval "() => ({ url: window.location.href, title: document.title })"

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