mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
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:
parent
ce341ae5b5
commit
f6d63f7c99
@ -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();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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();
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
@ -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()
|
||||
```
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user