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:02, 23 May 2024
, 23 May→Assertions
m (→Assertions) |
|||
Line 235: | Line 235: | ||
=== Assertions === | === Assertions === | ||
<nowiki> // General assertions | |||
const value = 5 | |||
expect(value).toEqual(5) | |||
const basicFormButton = page | |||
.locator("nb-card") | |||
.filter({ hasText: "Basic Form" }) | |||
.locator("button") | |||
const text = await basicFormButton.textContent() | |||
expect(text).toEqual("Submit") | |||
// locator assertion | |||
await expect(basicFormButton).toHaveText("Submit") | |||
// soft assertion (continues even if it fails) | |||
await expect.soft(basicFormButton).toHaveText("Submit") | |||
await basicFormButton.click()</nowiki> |