diff --git a/tests/page/selectors-text.spec.ts b/tests/page/selectors-text.spec.ts
index e57d4550be..e0c1e6547a 100644
--- a/tests/page/selectors-text.spec.ts
+++ b/tests/page/selectors-text.spec.ts
@@ -404,3 +404,10 @@ it('should match root after >> with *', async ({ page }) => {
await page.setContent(` `);
expect(await page.$$eval('*css=button >> text=hello >> text=world', els => els.length)).toBe(2);
});
+
+it('should work with leading and trailing spaces', async ({ page }) => {
+ it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/10997' });
+ await page.setContent(``);
+ await expect(page.locator('text=Add widget')).toBeVisible();
+ await expect(page.locator('text= Add widget ')).toBeVisible();
+});