docs(intro): Fix writing assertions snippet (#8372)

Fixes #8333
This commit is contained in:
Anish Karandikar 2021-08-23 13:50:56 -07:00 committed by GitHub
parent c8f3c65d22
commit 4dac4772ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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');