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 04:16, 24 May 2024
, 24 May→Lists & Dropdowns
m (→Checkboxes) |
|||
Line 429: | Line 429: | ||
=== Lists & Dropdowns === | === Lists & Dropdowns === | ||
<nowiki> | |||
test("lists and dropdowns", async ({ page }) => { | |||
const dropDownMenu = page.locator("ngx-header nb-select") | |||
await dropDownMenu.click() | |||
page.getByRole("list") // for <ul> => parent list container | |||
page.getByRole("listitem") // for <li> => not always used | |||
// const optionList = page.getByRole('list').locator('nb-option') | |||
const optionList = page.locator("nb-option-list nb-option") | |||
await expect(optionList).toHaveText(["Light", "Dark", "Cosmic", "Corporate"]) | |||
await optionList.filter({ hasText: "Cosmic" }).click() | |||
const header = page.locator("nb-layout-header") | |||
await expect(header).toHaveCSS("background-color", "rgb(50, 50, 89)") | |||
const colors = { | |||
Light: "rgb(255, 255, 255)", | |||
Dark: "rgb(34, 43, 69)", | |||
Cosmic: "rgb(50, 50, 89)", | |||
Corporate: "rgb(255, 255, 255)", | |||
} | |||
for (const color in colors) { | |||
await dropDownMenu.click() | |||
await optionList.filter({ hasText: color }).click() | |||
await expect(header).toHaveCSS("background-color", colors[color]) | |||
} | |||
})</nowiki> | |||
=== Tooltips === | === Tooltips === | ||
=== Dailog Boxes === | === Dailog Boxes === |