From 4dac4772ca85c9e49b779184d5f40b3b2ddb3ae2 Mon Sep 17 00:00:00 2001 From: Anish Karandikar Date: Mon, 23 Aug 2021 13:50:56 -0700 Subject: [PATCH] docs(intro): Fix writing assertions snippet (#8372) Fixes #8333 --- docs/src/intro-js.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/src/intro-js.md b/docs/src/intro-js.md index 4c91499da0..db57da7440 100644 --- a/docs/src/intro-js.md +++ b/docs/src/intro-js.md @@ -100,17 +100,17 @@ test('my test', async ({ page }) => { await page.goto('https://playwright.dev/'); // Expect a title "to contain" a substring. - await expect(page).toHaveTitle('Playwright'); + await expect(page).toHaveTitle(/Playwright/); // Expect an attribute "to be strictly equal" to the value. - await expect(page.locator('text=Get Started')).toHaveAttribute('href', '/docs/intro'); + await expect(page.locator('text=Get Started').first()).toHaveAttribute('href', '/docs/intro'); // Expect an element "to be visible". - await expect(page.locator('text=Learn more')).toBeVisible(); + await expect(page.locator('text=Learn more').first()).toBeVisible(); await page.click('text=Get Started'); // Expect some text to be visible on the page. - await expect(page.locator('text=System requirements')).toBeVisible(); + await expect(page.locator('text=System requirements').first()).toBeVisible(); // Compare screenshot with a stored reference. expect(await page.screenshot()).toMatchSnapshot('get-started.png'); @@ -125,17 +125,17 @@ test('my test', async ({ page }) => { await page.goto('https://playwright.dev/'); // Expect a title "to contain" a substring. - await expect(page).toHaveTitle('Playwright'); + await expect(page).toHaveTitle(/Playwright/); // Expect an attribute "to be strictly equal" to the value. - await expect(page.locator('text=Get Started')).toHaveAttribute('href', '/docs/intro'); + await expect(page.locator('text=Get Started').first()).toHaveAttribute('href', '/docs/intro'); // Expect an element "to be visible". - await expect(page.locator('text=Learn more')).toBeVisible(); + await expect(page.locator('text=Learn more').first()).toBeVisible(); await page.click('text=Get Started'); // Expect some text to be visible on the page. - await expect(page.locator('text=System requirements')).toBeVisible(); + await expect(page.locator('text=System requirements').first()).toBeVisible(); // Compare screenshot with a stored reference. expect(await page.screenshot()).toMatchSnapshot('get-started.png');