BrauzerLab
← Back to missions 35 / 50

Exact vs Contains

Easy ~120 sec

The page on the right has a heading: “Welcome, user!”. Your job: assert that this heading contains the sub-text 'Welcome' using expect.

In Playwright, expect assertions verify the state of the DOM. The difference between toHaveText and toContainText matters: the first expects an exact full-text match, while the second looks for a substring — that distinction is the main focus of this mission.

The page object is already available. Find the #greeting element and write your assertion.

There are several ways to locate the heading: locator, getByTestId, getByRole — all are accepted.

TASK

Assert the heading text.

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

test('Exact vs Contains', async ({ page }) => {
  await page.goto('https://lab.local/mission/text-vs-contain');
  // ↓ Your code goes below ↓
});
Editor
https://lab.local/mission/text-vs-contain
Loading...
Results will appear here — press Run or Check.