Playwright + Python · Lesson 17 of 37

0/37 done

Module 17: Web Element Actions

17. Hardware Actions: Clicks, Typing, Checkboxes & Hover

16 minlesson

Your task

Implement fill_credentials_and_submit(page, email, password):

  1. page.get_by_label("Email").fill(email)
  2. page.get_by_label("Password").fill(password)
  3. page.get_by_role("button", name="Sign In").click()

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

Core Actions in Python

python
page.get_by_label("Username").fill("sdet_pro")
page.get_by_label("Username").clear()

page.get_by_label("Subscribe").check()
page.locator("#country").select_option("Canada")

page.get_by_role("button", name="Menu").hover()
page.locator("#source").drag_to(page.locator("#target"))

Key Takeaways & Walkthrough Summary

Playwright actions dispatch trusted hardware events that mimic human user interactions. In this lesson, you will master fill, click, check, uncheck, select_option, hover, and drag_to. Let's explore element actions!

Part of the Playwright + Python course (Playwright with Python). 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()?

fill() instantly sets the value after checking actionability. type() types character-by-character, useful for auto-suggest testing.

Ready? Solve the task in the editor

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

Python
Skip