BrauzerLab
← Back to missions 29 / 50

`name=` Makes the Locator Unique

Easy ~120 sec

The account settings page has two buttons: Save and Delete. Your job is to click the Delete button.

A broad locator like getByRole('button') can match both buttons, potentially clicking the wrong one. A role-based locator with { name: 'Delete' } ensures only the button with that name is targeted.

page is ready and the DOM contains two buttons. Regardless of which approach you use, clicking the correct button passes the mission.

There are several valid approaches — getByRole, locator('#id'), and getByTestId all work.

TASK

Click the «Delete» button by its name.

Provided for you
import { test, expect } from '@playwright/test';

test('`name=` Makes the Locator Unique', async ({ page }) => {
  await page.goto('https://lab.local/mission/role-with-name');
  // ↓ Your code goes below ↓
});
Editor
https://lab.local/mission/role-with-name
Loading...
Results will appear here — press Run or Check.