Skip to content

[Bug]: Possible regression with chained locators in v1.42 #29760

@Mamaduka

Description

@Mamaduka

Version

1.42

Steps to reproduce

Example test:

const { chromium, test, expect } = require( '@playwright/test' );

test( 'locator chaining regression', async () => {
	const browser = await chromium.launch();
	const context = await browser.newContext();
	const page = await context.newPage();

	await page.setContent( `
	<ul>
		<li aria-label="Dogs">
			Dogs
			<ul>
				<li>chihuahua</li>
				<li>rottweiler</li>
			</ul>
		</li>
	</ul>
` );

	const animas = page
		.getByRole( 'listitem', { name: 'Dogs' } )
		.getByRole( 'listitem' );

	await expect( animas ).toHaveText( [ 'chihuahua', 'rottweiler' ] );
	await expect( animas ).toHaveCount( 2 );
} );

Steps:

  1. Run this test.
  2. Observe failure in v1.42

Expected behavior

The chained locator should resolve two elements.

Actual behavior

The chained locator resolves three elements, including the parent.

Additional context

No response

Environment

System:
    OS: macOS 13.3
    Memory: 545.13 MB / 16.00 GB
  Binaries:
    Node: 20.10.0 - ~/Library/Caches/fnm_multishells/9899_1709293478760/bin/node
    Yarn: 1.22.18 - /opt/homebrew/bin/yarn
    npm: 10.2.3 - ~/Library/Caches/fnm_multishells/9899_1709293478760/bin/npm
  Languages:
    Bash: 3.2.57 - /bin/bash
  Playwright: v1.42

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions