Marius
Marius

Reputation: 2008

getting input value and matching using playwright test runner

Using await page.inputValue('input') to get the input value and it returns the actual value but how do i test for it?

I have tried something like this await expect(page.inputValue('input')).toHaveValue('10'); but that does not work.

Upvotes: 1

Views: 4203

Answers (2)

Pablo
Pablo

Reputation: 350

You can use this:

const value = await page.inputValue('input');
expect(value).toEqual('10')

or shorter

expect(await page.inputValue('input')).toEqual('10')

Upvotes: 2

Alapan Das
Alapan Das

Reputation: 18624

You have to use this:

await expect(page.locator('input')).toHaveValue('10')

Upvotes: 0

Related Questions