18. Simulating Real User Interactions & Hardware Events

Core Actions API

// 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");

Task

  • Implement validateFormSubmission:
  • 1. Accept formData containing email (string) and agreed (boolean).
  • 2. Return true if email contains '@' and agreed is true.
πŸ’‘Common doubts
Did you like the problem?
Lesson 18 of 35
JavaScript
Loading code editor…
Next