From 2e84c63f0dde208c42453058ab83df0b177ad70c Mon Sep 17 00:00:00 2001 From: Debbie O'Brien Date: Fri, 11 Nov 2022 16:24:26 +0100 Subject: [PATCH] docs: update locators in getting started (#18738) --- docs/src/intro-csharp.md | 4 ++-- docs/src/intro-python.md | 2 +- docs/src/writing-tests-java.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/src/intro-csharp.md b/docs/src/intro-csharp.md index 12c66b95cd..fff4913a28 100644 --- a/docs/src/intro-csharp.md +++ b/docs/src/intro-csharp.md @@ -110,7 +110,7 @@ public class Tests : PageTest await Expect(Page).ToHaveTitleAsync(new Regex("Playwright")); // create a locator - var getStarted = Page.Locator("text=Get Started"); + var getStarted = Page.GetByRole(AriaRole.Link, new() { NameString = "Get started" }); // Expect an attribute "to be strictly equal" to the value. await Expect(getStarted).ToHaveAttributeAsync("href", "/docs/intro"); @@ -145,7 +145,7 @@ public class UnitTest1 : PageTest await Expect(Page).ToHaveTitleAsync(new Regex("Playwright")); // create a locator - var getStarted = Page.Locator("text=Get Started"); + var getStarted = Page.GetByRole(AriaRole.Link, new() { NameString = "Get started" }); // Expect an attribute "to be strictly equal" to the value. await Expect(getStarted).ToHaveAttributeAsync("href", "/docs/intro"); diff --git a/docs/src/intro-python.md b/docs/src/intro-python.md index 31f42740a3..7f49c8def0 100644 --- a/docs/src/intro-python.md +++ b/docs/src/intro-python.md @@ -37,7 +37,7 @@ def test_homepage_has_Playwright_in_title_and_get_started_link_linking_to_the_in expect(page).to_have_title(re.compile("Playwright")) # create a locator - get_started = page.locator("text=Get Started") + get_started = page.get_by_role("link", name="Get started") # Expect an attribute "to be strictly equal" to the value. expect(get_started).to_have_attribute("href", "/docs/intro") diff --git a/docs/src/writing-tests-java.md b/docs/src/writing-tests-java.md index 46de515304..b580bd9b75 100644 --- a/docs/src/writing-tests-java.md +++ b/docs/src/writing-tests-java.md @@ -26,7 +26,7 @@ public class App { assertThat(page).hasTitle(Pattern.compile("Playwright")); // create a locator - Locator getStarted = page.locator("text=Get Started"); + Locator getStarted = page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Get Started")) // Expect an attribute "to be strictly equal" to the value. assertThat(getStarted).hasAttribute("href", "/docs/intro");