Skip to content

[Bug]: ARIA Snapshot Missing in "Copy Prompt" when using browser.newPage() #35325

@MartinTellevik

Description

@MartinTellevik

Version

1.51.1

Steps to reproduce

  1. Create a test and create a new page with browser.newPage().
test('Demo', async ({ browser }) => {
  const page = await browser.newPage();
  await page.goto('https://playwright.dev/');
  await page.getByRole('link', { name: 'Get started' }).click();
  await expect(page.locator('non-existent-element')).toHaveText('test'); // For example
});
  1. Inspect the "Copy prompt" output.

Expected behavior

The ARIA snapshot should be included in the "Copy prompt" result.

Actual behavior

Here is my copy prompt result

Instructions

  • Following Playwright test failed.
  • Explain why, be concise, respect Playwright best practices.
  • Provide a snippet of code with the fix, if possible.

Test info

  • Name: Demo
  • Location: \demo\tests\example.spec.ts:3:5

Error details

Error: Timed out 5000ms waiting for expect(locator).toHaveText(expected)

Locator: locator('non-existent-element')
Expected string: "test"
Received: <element(s) not found>
Call log:
  - expect.toHaveText with timeout 5000ms
  - waiting for locator('non-existent-element')

    at \demo\tests\example.spec.ts:7:54

Test source

  1 | import { test, expect } from '@playwright/test';
  2 |
  3 | test('Demo', async ({ browser }) => {
  4 |   const page = await browser.newPage();
  5 |   await page.goto('https://playwright.dev/');
  6 |   await page.getByRole('link', { name: 'Get started' }).click();
> 7 |   await expect(page.locator('non-existent-element')).toHaveText('test'); // For example
    |                                                      ^ Error: Timed out 5000ms waiting for expect(locator).toHaveText(expected)
  8 | });
  9 |

Additional context

No response

Environment

System:
    OS: Windows 11 10.0.26100
    CPU: (32) x64 AMD Ryzen 9 5950X 16-Core Processor
    Memory: 26.82 GB / 63.92 GB
  Binaries:
    Node: 20.18.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    @playwright/test: ^1.51.1 => 1.51.1

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions