Playwright + Java · Lesson 18 of 38

0/38 done

Module 18: Web Element Actions

18. Hardware Simulation: Clicks, Typing & Mouse Interactions

16 minlesson

Your task

Implement fillAndSubmit:

  1. Accept Page page, String email, and String password.
  2. Fill page.getByLabel("Email") with email.
  3. Fill page.getByLabel("Password") with password.
  4. Click page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Log In")).

Write it in the editor, then press Check answer (Ctrl + Enter).

Essential Playwright Actions

java
page.getByLabel("Username").fill("automation_sdet");
page.getByLabel("Username").clear();

page.getByLabel("I agree to terms").check();
page.locator("#country-select").selectOption("US");
page.locator("#menu-dropdown").hover();
page.keyboard().press("Control+A");

Key Takeaways & Walkthrough Summary

Playwright executes hardware-level interactions that simulate real human users. In this lesson, you will master clicking, filling text fields, checking checkboxes, selecting dropdown options, hovering, and keyboard combinations. Let's explore element actions!

Part of the Playwright + Java course (Playwright with Java). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.

Common Doubts & Lesson Q&A

What is the difference between fill() and type() in Playwright Java?

fill() clears the input and inserts the whole text instantly after awaiting actionability. type() presses each key one by one.

Ready? Solve the task in the editor

Use Check answer to mark it complete. Hints are there if you need them.

Java
Skip