docs: update locators in getting started (#18738)
This commit is contained in:
parent
ad5fe28416
commit
2e84c63f0d
|
|
@ -110,7 +110,7 @@ public class Tests : PageTest
|
||||||
await Expect(Page).ToHaveTitleAsync(new Regex("Playwright"));
|
await Expect(Page).ToHaveTitleAsync(new Regex("Playwright"));
|
||||||
|
|
||||||
// create a locator
|
// 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.
|
// Expect an attribute "to be strictly equal" to the value.
|
||||||
await Expect(getStarted).ToHaveAttributeAsync("href", "/docs/intro");
|
await Expect(getStarted).ToHaveAttributeAsync("href", "/docs/intro");
|
||||||
|
|
@ -145,7 +145,7 @@ public class UnitTest1 : PageTest
|
||||||
await Expect(Page).ToHaveTitleAsync(new Regex("Playwright"));
|
await Expect(Page).ToHaveTitleAsync(new Regex("Playwright"));
|
||||||
|
|
||||||
// create a locator
|
// 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.
|
// Expect an attribute "to be strictly equal" to the value.
|
||||||
await Expect(getStarted).ToHaveAttributeAsync("href", "/docs/intro");
|
await Expect(getStarted).ToHaveAttributeAsync("href", "/docs/intro");
|
||||||
|
|
|
||||||
|
|
@ -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"))
|
expect(page).to_have_title(re.compile("Playwright"))
|
||||||
|
|
||||||
# create a locator
|
# 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 an attribute "to be strictly equal" to the value.
|
||||||
expect(get_started).to_have_attribute("href", "/docs/intro")
|
expect(get_started).to_have_attribute("href", "/docs/intro")
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public class App {
|
||||||
assertThat(page).hasTitle(Pattern.compile("Playwright"));
|
assertThat(page).hasTitle(Pattern.compile("Playwright"));
|
||||||
|
|
||||||
// create a locator
|
// 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.
|
// Expect an attribute "to be strictly equal" to the value.
|
||||||
assertThat(getStarted).hasAttribute("href", "/docs/intro");
|
assertThat(getStarted).hasAttribute("href", "/docs/intro");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue