Chapter 40: Click, fill and keyboard actions
Automation learning lab
Playwright Automation
Self Study Guide
Start from zero. Learn JavaScript and TypeScript, automate browsers, and build reliable end-to-end tests.
Click, fill and keyboard actions
Use click for interactive controls, fill for editable inputs, and press for keyboard keys or shortcuts. fill sets the value and triggers an input event; press sends a key interaction. Actions wait for relevant actionability conditions.
How it works
Step-by-step walkthrough
- Create an input
- Fill the text
- Check the value
Example
import { test, expect } from '@playwright/test';
test('chapter 40 practice', async ({ page }) => {
await page.setContent('<label>Search <input></label>');
const input = page.getByLabel('Search');
await input.fill('Playwright');
await input.press('End');
await expect(input).toHaveValue('Playwright');
});Do not use force unless you understand which checks are skipped.
Practice application screenshot
✎ Your practice task
Clear the input and verify its empty value.
Knowledge check
Which action sets a text input value?
🌐 Continue learning
60-chapter learning path
Start at chapter 1, or choose any topic. Your progress is tracked separately for each chapter.
JavaScript fundamentals
TypeScript fundamentals
Playwright • setup & locators
Playwright • interactions & assertions
Playwright • framework & debugging
Playwright • real-world automation
Interactive practice lab
Try the controls below and observe the corresponding Playwright locator instructions. This browser demo does not execute Node.js or Playwright Test; copy the code to your local Playwright project to automate it.
Task manager demo
Suggested automation
Actions on the demo update these examples. In your local test use a page that contains the same controls.
Download a standalone lab page, then serve it locally (for example with Python's http.server). Navigate to it in a Playwright test.