# How to Read Textbox Values in Playwright Tests

Playwright encourages using
[locator methods](https://playwright.dev/docs/locators) to select elements on
your web pages. To read textbox values, you can use the
`inputValue()` method on a locator pointing
to the textbox. Here's how:

```javascript
import { test, expect } from '@playwright/test';

test('Read textbox value', async ({ page }) => {
  await page.goto('https://yourwebsite.com');

  const textboxLocator = page.locator('#myTextbox');

[highlight]
  const textboxValue = await textboxLocator.inputValue();
[/highlight]

  console.log(textboxValue);
});
```

You can also combine getting and verifying the value of a textbox in a single
step like this:

```javascript
import { test, expect } from '@playwright/test';

test('Read textbox value', async ({ page }) => {
  await page.goto('https://yourwebsite.com');

  const textboxLocator = page.locator('#myTextbox');

[highlight]
  await expect(textboxLocator).toHaveValue('my_value');
[/highlight]
});
```

Thanks for reading, and happy coding!

[summary]

## 🔭 Want to automate and scale your Playwright end-to-end tests?

Head over to [Better Stack](https://betterstack.com/website-monitoring) and
start monitoring in 5 minutes. [/summary]

[ad-uptime]
