0

I am using Playwright in C#. I have a text box:

<input id="NameFirst" name="NameFirst" type="text" >

In my Playwright test, I need to check to see if the name populating the text box is equal to the string "firstName".

This is what I have tried (along with practically every other Playwright assertion): await Expect(RMSPage.Locator("#NameFirst")).ToContainTextAsync("firstName");

Here is the error I am receiving:

Microsoft.Playwright.PlaywrightException : Locator expected to contain text 'firstName'
But was: ''
hardkoded
  • 18,915
  • 3
  • 52
  • 64
Dusty Shaw
  • 38
  • 6

1 Answers1

0

What you want is to get the value of the input. You need to use ToHaveValueAsync

await Expect(RMSPage.Locator("#NameFirst")).ToHaveValueAsync("firstName");
hardkoded
  • 18,915
  • 3
  • 52
  • 64