Playwright + JS · Lesson 18 of 35
Module 18: Actions
Try it yourself
Implement validateFormSubmission:
The editor has a worked example. Read it, tweak it, then press Mark as complete.
// Inputs & Forms:
await page.getByLabel("Email").fill("qa@targetqa.com");
await page.getByLabel("Agree to Terms").check();
await page.getByLabel("Country").selectOption("CA");
// Gestures & Drag and drop:
await page.getByTestId("profile-avatar").hover();
await page.locator("#drag-source").dragTo(page.locator("#drop-target"));
// File upload:
await page.getByLabel("Upload Profile Picture").setInputFiles("test-data/avatar.png");Playwright actions simulate real hardware-level user input. Before executing any click or keypress, Playwright automatically checks that the target element is visible, stable, enabled, and ready to receive events. Let's master user actions!
Part of the Playwright + JS course (Playwright with JavaScript). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.
fill() sets the input value directly and dispatches input/change events. If you specifically need keydown/keyup events, use pressSequentially().
Finished reading?
Review the worked example in the editor, then mark the lesson complete.