Error: expect(locator).toBeVisible() failed
12:35 23 Sep 2026

When I run my test in Playwright the assertion always fails. It does not match the h2 element even though the page does display it.

My test code:

import {test, expect, Locator} from "@playwright/test"

test("In Built Locators", async({page})=>{

await page.goto("https://demo.nopcommerce.com/");

await expect(page.getByText("welcome to our store")).toBeVisible({ timeout: 5000 });


})

Log Error:

Error: expect(locator).toBeVisible() failed

    Locator: getByText('welcome to our store')
    Expected: visible
    Timeout: 5000ms
    Error: element(s) not found

    Call log:
      - Expect "toBeVisible" getByText('welcome to our store') with timeout 5000ms
      - waiting for getByText('welcome to our store')
typescript playwright