Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs: update example test assertion (#24554)

Debbie O'Brienf6d63f7c99ce
diff --git a/docs/src/writing-tests-csharp.md b/docs/src/writing-tests-csharp.md
index 6542ae5c78..3818b9f039 100644
--- a/docs/src/writing-tests-csharp.md
+++ b/docs/src/writing-tests-csharp.md
@@ -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();
}
}
```
diff --git a/docs/src/writing-tests-java.md b/docs/src/writing-tests-java.md
index ababca5a06..c6e10731fa 100644
--- a/docs/src/writing-tests-java.md
+++ b/docs/src/writing-tests-java.md
@@ -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();
}
}
}
diff --git a/docs/src/writing-tests-js.md b/docs/src/writing-tests-js.md
index cad8e0861a..bebfa460e9 100644
--- a/docs/src/writing-tests-js.md
+++ b/docs/src/writing-tests-js.md
@@ -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();
});
```
diff --git a/docs/src/writing-tests-python.md b/docs/src/writing-tests-python.md
index 1ec2a6d876..45efdb2223 100644
--- a/docs/src/writing-tests-python.md
+++ b/docs/src/writing-tests-python.md
@@ -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()
```