docs: update locators in getting started (#18738)

This commit is contained in:
Debbie O'Brien 2022-11-11 16:24:26 +01:00 committed by GitHub
parent ad5fe28416
commit 2e84c63f0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

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

View File

@ -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")

View File

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