SoftwareTestPilot
LearnCoding RoundsCommunityJobsQA Resources
All questions
BasicPlaywright~6 min

Playwright: log in with user-facing locators

First Playwright task in most automation interviews

Points available

100/100

Your mission

  1. Read
  2. 2Run
  3. 3Submit
  4. 4Solve

page is a Playwright-style page. Write login(page, user, pass) that fills the Username and Password fields (find them by label) and clicks the Sign in button (find it by role).

Use getByLabel and getByRole — no CSS selectors.

`page` is a Playwright-style practice page running in your browser: getByRole, getByLabel, getByText, getByTestId, locator chaining, filter, nth and auto-waiting actions work like the real API.

Hints

Each hint costs 10 points on a full solve.

Interviewer follow-ups

  • Why prefer role/label locators over XPath?
  • How would you assert you reached the dashboard?

Ctrl+Enter to run · add Shift to submit

1
2
3
4
Tab inserts two spaces. Press Escape, then Tab, to leave the editor.
Terminal

$ node solution.js

Run executes the open file. Submit scores solution.js against hidden tests.

SoftwareTestPilot

Learn QA, prove your skills, connect with testers and grow your career.

Platform
  • Learn
  • Community
  • Jobs
Resources
  • QA Resources
  • Interview Questions
  • QA Tools
  • Articles
  • Products
Company
  • About
  • Contact
  • Authors & Reviewers
  • Editorial Policy
  • Sitemap
© 2026 SoftwareTestPilot. All rights reserved.
Operated by SoftwareTestPilot · Pune, Maharashtra, India · softwaretestingsapiens@gmail.com
PrivacyTermsCookiesDisclaimerRefundsAccessibility