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 23:09, 20 May 2024
, 20 May→x
m (→x) |
|||
Line 135: | Line 135: | ||
use <code>npx playwright test --ui</code> and click the watch icon so that test auto-re-runs when you edit the code ''(I love this)'' | use <code>npx playwright test --ui</code> and click the watch icon so that test auto-re-runs when you edit the code ''(I love this)'' | ||
==== | ==== User Facing Locators ==== | ||
[https://playwright.dev/docs/best-practices Playwright Best Practices] | |||
* Test user-visible behaviour | |||
** tests should typically only see/interact with rendered output | |||
** mimic user behaviour | |||
* page.getByRole(...) | |||
** See ARIA roles and attributes (google it?) | |||
<nowiki> | |||
await page.getByRole("textbox", { name: "Email" }).first().click() | |||
await page.getByRole("button", { name: "Sign in" }).first().click() | |||
await page.getByLabel("Email").first().click() | |||
await page.getByPlaceholder('Jane Doe').click() | |||
await page.getByText('Using the Grid').click() | |||
await page.getByTestId('SignIn').click() // this expects html attribute=> data-testid="SignIn" | |||
await page.getByTitle('IoT Dashboard').click()</nowiki> | |||
==== Child Elements ==== |