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:47, 23 May 2024
, 23 May→Extracting Values
m (→x) |
|||
Line 214: | Line 214: | ||
=== Extracting Values === | === Extracting Values === | ||
<nowiki> | |||
// Single test value | |||
const basicForm = page.locator("nb-card").filter({ hasText: "Basic Form" }) | |||
const buttonText = await basicForm.locator('button').textContent() | |||
expect(buttonText).toEqual("Submit") | |||
// Array of text values | |||
const allRadioButtonLabels = await page.locator('nb-radio').allTextContents() | |||
expect(allRadioButtonLabels).toContain('Option 1') | |||
// input value | |||
const emailField = basicForm.getByRole('textbox', {name: 'Email'}) | |||
await emailField.fill('test@test.com') | |||
const emailValue = await emailField.inputValue() | |||
expect(emailValue).toEqual('test@test.com') | |||
// attribute | |||
const placeholderValue = await emailField.getAttribute('placeholder') | |||
expect(placeholderValue).toEqual('Email')</nowiki> | |||
=== Assertions === |