Skip to content

[BUG] trailing zero width whitespace fails toHaveText #10620

@jtgober

Description

@jtgober

Context:

  • Playwright Version: 1.16.3
  • Operating System: Windows
  • Node.js version: 14.18.1
  • Browser: chromium
  • Extra: n/a
const { test, expect } = require('@playwright/test');

test('basic test', async ({ page }) => {
  await page.goto('https://playwright.dev/');
  await page.locator('text=Get started').click();
  await expect(page.locator('#installation')).toHaveText("Installation​");
});

The issue has to do with the expect statement when this is ran, it fails the test. However, see the expected v.s. the received

Error: expect(received).toHaveText(expected)

Expected string: "Installation"
Received string: "Installation​"

What is bizarre, is if I were to copy/paste the Received string: "Installation​" into the toHaveText field, it comes back successful, although there are no changes.

PW.weirdness.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions