Udemy Playwright: Web Automation Testing From Zero to Hero: Difference between revisions
Jump to navigation
Jump to search
Udemy Playwright: Web Automation Testing From Zero to Hero (view source)
Revision as of 03:30, 23 May 2024
, 23 May→x
m (→x) |
|||
Line 199: | Line 199: | ||
I think I like best the last one, where you select something that looks like a heading to the user, and then go to the parent that contains the selected element, and the element you want to locate. | I think I like best the last one, where you select something that looks like a heading to the user, and then go to the parent that contains the selected element, and the element you want to locate. | ||
==== | === Reusing Locators === | ||
Stop copying and pasting code .... | |||
<nowiki> | |||
const testEmailAddress = "test@test.com" | |||
const basicForm = page.locator("nb-card").filter({ hasText: "Basic Form" }) | |||
const emailField = basicForm.getByRole("textbox", { name: "Email" }) | |||
await emailField.fill(testEmailAddress) | |||
await basicForm.getByRole("textbox", { name: "Password" }).fill("Welcome123") | |||
await basicForm.getByRole("button").click() | |||
await expect(emailField).toHaveValue(testEmailAddress)</nowiki> | |||
=== Extracting Values === |