Skip to content
CodeKruPro

expect - toHaveValue

35/70

Playwright Assertions: toHaveValue

await expect(locator).toHaveValue(expected) asserts the input's current value.

Task:

  1. Navigate to https://testkru.com/Elements/TextFields
  2. Assert the pre-filled field (#preFilledTextField) has value "Codekru"
  3. Fill #lastNameWithPlaceholder with "TestUser"
  4. Assert it has value "TestUser"
  5. Print confirmation after each

Expected output:

Pre-filled value assertion: PASS
Filled value assertion: PASS