getting input value and matching using playwright test runner

Viewed 88

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.

2 Answers

You have to use this:

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

You can use this:

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

or shorter

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