Udemy Playwright: Web Automation Testing From Zero to Hero: Difference between revisions

Jump to navigation Jump to search
m
Line 101: Line 101:


== Section 4: Interaction with Web Elements ==
== Section 4: Interaction with Web Elements ==
=== Understanding DOM and Terminology ===
=== Understanding DOM and Terminology - Review HTML terms ===  
==== Review HTML terms ====  
  <nowiki>
  <nowiki>
<parent>
<parent>
Line 113: Line 112:
</parent></nowiki>
</parent></nowiki>


==== Locator Syntax Rules ====
=== Locator Syntax Rules ===
  <nowiki>
  <nowiki>
     page.locator('input') //finds all of them
     page.locator('input') //finds all of them
Line 135: Line 134:
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 ====
=== User Facing Locators ===


[https://playwright.dev/docs/best-practices Playwright Best Practices]
[https://playwright.dev/docs/best-practices Playwright Best Practices]
Line 155: Line 154:
   await page.getByTitle('IoT Dashboard').click()</nowiki>
   await page.getByTitle('IoT Dashboard').click()</nowiki>


==== Child Elements ====
=== Child Elements ===
  <nowiki>test("Locating child elements", async ({ page }) => {
  <nowiki>test("Locating child elements", async ({ page }) => {
   await page.locator('nb-card nb-radio :text-is("Option 1")').click()
   await page.locator('nb-card nb-radio :text-is("Option 1")').click()
Line 163: Line 162:
})</nowiki>
})</nowiki>


==== Parent Elements ====
=== Parent Elements ===
  <nowiki>
  <nowiki>
test("Locating parent elements", async ({ page }) => {
test("Locating parent elements", async ({ page }) => {

Navigation menu