docs: update example test assertion (#24554)

uses different assertion to make test visually better when using trace
viewer etc and is more realistic example
This commit is contained in:
Debbie O'Brien 2023-08-01 22:04:04 +02:00 committed by GitHub
parent ce341ae5b5
commit f6d63f7c99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 8 deletions

View File

@ -47,8 +47,10 @@ public class Tests : PageTest
// Click the get started link.
await getStarted.ClickAsync();
// Expects the URL to contain intro.
await Expect(Page).ToHaveURLAsync(new Regex(".*intro"));
// Expects page to have a heading with the name of Installation.
await Expect(page
.GetByRole(AriaRole.Heading, new() { Name = "Installation" }))
.ToBeVisibleAsync();
}
}
```

View File

@ -35,8 +35,9 @@ public class App {
// Click the get started link.
getStarted.click();
// Expects the URL to contain intro.
assertThat(page).hasURL(Pattern.compile(".*intro"));
// Expects page to have a heading with the name of Installation.
assertThat(page.getByRole(AriaRole.HEADING,
new Page.GetByRoleOptions().setName("Installation"))).isVisible();
}
}
}

View File

@ -47,8 +47,8 @@ test('get started link', async ({ page }) => {
// Click the get started link.
await page.getByRole('link', { name: 'Get started' }).click();
// Expects the URL to contain intro.
await expect(page).toHaveURL(/.*intro/);
// Expects page to have a heading with the name of Installation.
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
});
```

View File

@ -27,8 +27,8 @@ def test_homepage_has_Playwright_in_title_and_get_started_link_linking_to_the_in
# Click the get started link.
get_started.click()
# Expects the URL to contain intro.
expect(page).to_have_url(re.compile(".*intro"))
# Expects page to have a heading with the name of Installation.
expect(page.get_by_role("heading", name="Installation")).to_be_visible()
```