Resource library

Automation Interview

Playwright Interview Questions for 1 Years Experience (2026)

Prepare playwright interview questions 1 years experience with junior-level answers, TypeScript examples, locator guidance, debugging, and a study plan.

24 min read | 2,989 words

TL;DR

At one year of experience, expect Playwright questions on test structure, Locators, auto-waiting, assertions, browser-context isolation, basic interactions, and debugging. Strong answers pair a correct concept with a small example and avoid claiming senior framework ownership.

Key Takeaways

  • Master BrowserContext, Page, Locator, fixtures, and web-first assertions before memorizing advanced APIs.
  • Use role, label, and scoped test-id locators instead of generated classes or DOM-order selectors.
  • Explain auto-waiting as actionability checks, then assert the separate business outcome.
  • Keep tests independent with isolated contexts and deterministic data.
  • Debug from errors, action logs, Inspector, and traces before adding retries or longer timeouts.
  • Show honest one-year contributions with specific actions, evidence, and learning.

Playwright interview questions 1 years experience candidates receive usually test practical fundamentals, not framework architecture. You should be ready to explain locators, auto-waiting, assertions, browser contexts, basic debugging, and one small TypeScript test in clear language.

A strong one-year candidate does not pretend to be a senior engineer. Instead, show that you can create readable tests, diagnose ordinary failures, ask good questions about risk, and improve from evidence. This guide gives you the technical baseline, runnable examples, and model answers needed for that level.

TL;DR

Interview area What a credible one-year answer demonstrates
Test structure Clear arrange, act, assert flow and independent tests
Locators Preference for role, label, text, and test id over brittle DOM paths
Waiting Understanding of auto-waiting and web-first assertions
Isolation A fresh browser context and controlled data per test
Debugging Ability to use error logs, Inspector, screenshots, and traces
Coding Correct async and await, assertions, and scoped Locators
QA thinking Coverage of happy, negative, boundary, and accessibility-relevant paths

Your goal is not to recite every API. Explain why you chose an API and what evidence would tell you whether a failure is in the test, product, data, or environment.

1. Playwright Interview Questions 1 Years Experience Candidates Should Expect

At one year, interviews usually mix testing fundamentals with Playwright basics. A screening round may ask what Playwright is, why teams choose it, and how it differs from Selenium at a high level. A technical round may show an unstable selector, ask you to write a login test, or ask why a timeout occurs. A practical round may require a small repository change.

Interviewers are looking for working habits:

  • You await browser actions and understand asynchronous execution.
  • You choose Locators based on user-facing semantics.
  • You assert outcomes rather than only performing clicks.
  • You know that each test should be independently repeatable.
  • You avoid fixed waits and use Playwright's waiting model.
  • You can open a trace or Inspector rather than guessing.
  • You communicate what you know and what you would verify.

A junior answer becomes credible when it includes one reason and one example. For instance, do not say only, "getByRole is best." Say that role plus accessible name describes how a user and accessibility tree identify the control, and demonstrate getByRole('button', { name: 'Sign in' }).

Do not oversell production ownership you did not have. If you contributed tests under review, describe your contribution, the feedback you received, and the defect or stability improvement that followed. Honest specificity beats inflated titles.

2. Build the Right Playwright Mental Model

Playwright is browser automation tooling, and Playwright Test is its test runner with fixtures, assertions, projects, retries, reporters, and parallel execution. In a typical test, the runner supplies a Page fixture. The Page belongs to an isolated BrowserContext, which behaves like an incognito browser profile with its own cookies and storage.

A Locator is a reusable query for finding elements. It resolves when an action or assertion runs, which helps when a React or Vue application rerenders. Actions such as click and fill perform relevant actionability checks. Assertions such as toBeVisible and toHaveText retry until the expected state appears or the assertion timeout expires.

Understand these boundaries:

Concept Purpose Example
Browser Browser process managed by Playwright Chromium running for a worker
BrowserContext Isolated session Separate cookies for each test
Page One browser tab page.goto('/login')
Locator Element query evaluated on use page.getByLabel('Email')
Fixture Test dependency with lifecycle page, request, custom authenticatedPage
Assertion Verification with useful retry behavior expect(alert).toHaveText('Saved')

The mental model answers many interview questions. Tests are isolated because contexts do not share session state by default. Locators are safer than stored element handles because they re-resolve. Web-first assertions handle eventual UI updates without hard sleeps. This foundation matters more than memorizing dozens of methods.

3. Set Up and Explain a Basic Test

Be able to create a project and explain its files:

npm init playwright@latest
npx playwright test
npx playwright test --ui

A basic TypeScript test imports test and expect, navigates, interacts, and verifies a result:

import { test, expect } from '@playwright/test';

test('user signs in with valid credentials', async ({ page }) => {
  await page.goto('/login');

  await page.getByLabel('Email').fill('qa.user@example.com');
  await page.getByLabel('Password').fill('correct-password');
  await page.getByRole('button', { name: 'Sign in' }).click();

  await expect(page).toHaveURL(/\/dashboard$/);
  await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible();
});

Explain every await. Browser operations are asynchronous, and failing to await one can let the test move forward before the action completes. Explain why both assertions help: the URL confirms navigation, while the heading confirms meaningful page content.

In a real suite, do not commit a password in a spec. Read credentials from an environment variable or create users through a controlled test-data service. The literal string keeps the interview example easy to read, but mention the production adjustment.

A simple config demonstrates baseURL, trace collection, and browser projects:

import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  testDir: './tests',
  use: {
    baseURL: process.env.BASE_URL ?? 'http://127.0.0.1:3000',
    trace: 'on-first-retry'
  },
  projects: [
    { name: 'chromium', use: { ...devices['Desktop Chrome'] } },
    { name: 'firefox', use: { ...devices['Desktop Firefox'] } }
  ]
});

Know that config choices should match product risk. Running every test in every browser can be appropriate, but teams may use focused smoke coverage on pull requests and broader coverage later.

4. Use Locators and Assertions Correctly

Locator questions are common because poor selectors cause false failures. Prefer this order based on the UI contract:

  1. getByRole with accessible name for buttons, links, headings, and controls.
  2. getByLabel for labeled form fields.
  3. getByPlaceholder or getByText when visible content is stable and appropriate.
  4. getByTestId for a deliberate test contract where user-facing semantics are insufficient.
  5. CSS only when a stable semantic or test contract is unavailable.

Avoid long CSS chains, generated classes, and XPath tied to nesting. Scope repeated controls to a parent:

const row = page.getByRole('row', { name: /Avery Chen/ });
await row.getByRole('button', { name: 'Edit' }).click();

const dialog = page.getByRole('dialog', { name: 'Edit user' });
await expect(dialog).toBeVisible();
await expect(dialog.getByLabel('Email')).toHaveValue('avery@example.com');

Do not use first() merely to remove a strict-mode error. A strictness failure means the locator is ambiguous. Add scope or a stable identity.

Choose retrying assertions for browser state:

await expect(page.getByRole('status')).toHaveText('Profile saved');
await expect(page.getByRole('button', { name: 'Submit' })).toBeEnabled();
await expect(page).toHaveURL(/\/profile$/);

A generic expect(await locator.textContent()).toBe('Profile saved') captures one instant and does not provide the same web-first retry behavior. For a deeper study plan, read Playwright locators and assertions.

5. Explain Auto-Waiting Without Saying Playwright Waits for Everything

Playwright automatically waits for relevant actionability before actions. For a click, the target must satisfy checks such as visibility, stability, receiving events, and enabled state. The exact checks depend on the action. Navigation and assertion behavior are separate concerns, so "Playwright waits automatically" is incomplete.

Use an assertion for the state you need:

await page.getByRole('button', { name: 'Save' }).click();
await expect(page.getByRole('status')).toHaveText('Saved');

Avoid:

await page.getByRole('button', { name: 'Save' }).click();
await page.waitForTimeout(3000);

The sleep always costs three seconds and still fails if valid processing takes longer. The status assertion can pass as soon as the UI is ready and produces a meaningful error when it is not.

Know the main timeout scopes conceptually. A test has an overall timeout. Assertions have their own timeout. Individual actions can accept a timeout, and configuration can provide defaults. A longer timeout is not a root-cause fix. Check whether the locator is wrong, an overlay intercepts the action, the app never reached the expected state, or the environment is unhealthy.

The Playwright timeout troubleshooting guide is useful practice material. In an interview, describe the error and action log you would inspect before editing timeout values.

6. Cover Interactions, Isolation, and Test Data

You should be comfortable with click, fill, check, selectOption, upload through setInputFiles, keyboard input, and hover. Always link the action to an outcome.

test('filters orders by status', async ({ page }) => {
  await page.goto('/orders');

  await page.getByLabel('Status').selectOption('shipped');
  await expect(page.getByRole('row')).toHaveCount(4);
  await expect(page.getByRole('row', { name: /Pending/ })).toHaveCount(0);
});

Treat the numeric count as controlled fixture data, not a production assumption. Tests need known inputs. Create a unique entity through an API, seed a fixture database through an approved mechanism, or use a dedicated environment reset. Never make tests depend on execution order.

BrowserContext isolation means one test should not inherit cookies or local storage from another. Playwright Test creates an isolated context for each test by default. If authentication setup is expensive, a team can save storage state and start tests from it, while keeping state files out of source control if they contain sensitive session data.

Know the difference between shared setup and shared mutable state. A reusable login helper can be safe. Reusing one page across tests makes order dependence and parallel conflicts likely. At one year, explaining that distinction shows good instincts even if you did not design the full framework.

7. Debug a Failure With Evidence

Give interviewers a sequence, not "I rerun it." First read the failure, the action log, and the assertion diff. Reproduce the smallest test locally. Use headed mode, UI mode, or Inspector to observe behavior. Open the trace to inspect actions, DOM snapshots, network, console, and timing. Check screenshots or video when configured.

Useful commands include:

npx playwright test tests/profile.spec.ts --headed
npx playwright test tests/profile.spec.ts --debug
npx playwright show-report
npx playwright show-trace path/to/trace.zip

Classify the failure:

  • Product defect: the expected user behavior is wrong in a repeatable environment.
  • Test defect: locator, data, assertion, or sequence does not match the requirement.
  • Environment defect: service, dependency, deployment, or test infrastructure is unhealthy.
  • Flake: the result varies under apparently identical conditions and needs evidence-based investigation.

Do not immediately add a retry. A retry can provide trace evidence and protect a pipeline from a known low-frequency issue, but it does not make the first attempt correct. Record the failing attempt, find the causal condition, and fix it.

When reporting a defect, include environment, build, preconditions, exact steps, expected and actual results, evidence, and impact. Clear diagnosis is a QA skill, not merely a tool skill. Practice with the Playwright trace viewer guide.

8. Practice Playwright Interview Questions 1 Years Experience Coding Tasks

Most junior coding exercises are small. You may receive a login form, table, modal, or API endpoint. Start by restating the behavior and identifying stable selectors. Write one clear happy path, then add a negative or boundary check if time remains.

For example, test a validation message without overengineering:

import { test, expect } from '@playwright/test';

test('requires an email address', async ({ page }) => {
  await page.goto('/signup');

  await page.getByLabel('Password').fill('StrongPassword123!');
  await page.getByRole('button', { name: 'Create account' }).click();

  await expect(page.getByText('Email is required', { exact: true })).toBeVisible();
  await expect(page).toHaveURL(/\/signup$/);
});

Talk while coding. State why you selected getByLabel, what makes data deterministic, and how the assertion proves the requirement. If the page lacks accessible labels, mention the product accessibility issue and choose a test id if the exercise provides one.

Review async TypeScript basics: imports, const, arrays, objects, functions, regular expressions, Promise behavior, and try/finally for necessary cleanup. Avoid building a page object for a ten-line exercise unless requested. Correctness and readability matter more than patterns.

After writing, run the focused test, read any failure, and explain the next diagnostic step. A candidate who debugs calmly often scores better than one who memorizes a perfect solution but cannot explain a changed UI.

9. Build a Seven-Day Preparation Plan

Day 1: install a small project, run tests in UI mode, and explain Browser, BrowserContext, Page, Locator, fixture, and assertion in your own words.

Day 2: write tests for login, form validation, a table row, and a modal using role and label locators. Intentionally create an ambiguous locator, then fix it through scoping.

Day 3: replace every fixed sleep in a practice suite with an observable assertion or targeted wait. Study the difference between actionability and assertion retrying.

Day 4: add deterministic test data and one API setup call. Run tests in parallel and look for shared-state failures.

Day 5: break one selector, one API response, and one UI expectation. Diagnose each with Inspector and trace viewer, then write a short failure summary.

Day 6: complete a forty-five-minute coding exercise. Include a happy path, negative case, configuration, and README commands. Review naming and remove duplication only where it improves clarity.

Day 7: rehearse the Q&A below aloud. Use concise answers with an example. Prepare two honest stories: one defect you found and one flaky or failing test you investigated.

Do not spend the week memorizing method lists. Build, break, observe, and explain. That produces the practical recall interviewers want.

How to communicate during the interview

Keep technical answers short enough for follow-up. State the concept, give a concrete example, and name the reason. During coding, narrate locator choice, data assumptions, and the outcome you plan to assert. If a requirement is unclear, state a reasonable assumption instead of silently coding a different behavior.

When you encounter an error, read it aloud, isolate the failing layer, and explain the evidence you want next. Interviewers do not require instant perfection from a one-year candidate. They value a safe debugging process, willingness to correct an assumption, and code that becomes clearer after feedback.

Interview Questions and Answers

Q: What is Playwright?

Playwright is a browser automation library supporting Chromium, Firefox, and WebKit. Playwright Test adds a test runner, fixtures, assertions, projects, retries, parallel execution, and reporting. I use it to automate browser workflows with isolated contexts and locator-based interactions.

Q: What is the difference between Browser, BrowserContext, and Page?

Browser represents the browser process. BrowserContext is an isolated session with separate cookies and storage, similar to an incognito profile. Page represents a tab inside a context.

Q: What is a Locator?

A Locator describes how to find one or more elements and resolves when an action or assertion uses it. That makes it resilient to many rerenders. I prefer role, label, or stable test-id locators and scope them when repeated components exist.

Q: Why do you use getByRole?

getByRole can identify elements through accessible role and name, which often matches how users understand the interface. It produces readable tests and can reveal weak semantics. I still choose the locator based on the product contract rather than applying one method blindly.

Q: What is auto-waiting?

Before actions, Playwright waits for the target to satisfy the relevant actionability checks. For example, a click normally needs a visible, stable, enabled target that receives events. I separately assert the result because auto-waiting does not know the business outcome.

Q: Why should you avoid waitForTimeout?

It waits for time, not readiness. A sleep slows fast runs and still fails when the application is slower than the chosen delay. I wait for a visible, enabled, text, URL, response, or other state tied to the requirement.

Q: How do you handle a strict-mode locator failure?

I inspect all matches and refine the locator through accessible name, parent scope, stable data, or filter. I do not automatically use first() because that can select the wrong element and create order dependence.

Q: How do you test a new browser tab?

I begin waiting for the page event before the action that opens the tab, then await both and assert the new Page. Registering the wait first prevents missing a fast event.

const newPagePromise = page.context().waitForEvent('page');
await page.getByRole('link', { name: 'Open documentation' }).click();
const newPage = await newPagePromise;
await newPage.waitForLoadState();
await expect(newPage).toHaveURL(/docs/);

Q: How do you upload a file?

I locate the file input and call setInputFiles with a known test fixture path. Then I assert the uploaded filename or server-confirmed state. I keep fixture files small and deterministic.

Q: How do you debug a failed test?

I read the error, action log, and assertion diff, then reproduce the focused test. I use headed or debug mode and inspect the trace, screenshots, console, and network. I classify the issue before changing locators, waits, or retries.

Q: What is a fixture?

A fixture supplies a test dependency and manages setup and teardown around its lifecycle. Built-in fixtures include page and request. Custom fixtures can provide domain clients or prepared pages, but I keep their responsibilities focused.

Q: How do you keep tests independent?

Each test creates or receives controlled data and uses its own browser context. It does not depend on another test running first or mutating shared state. Cleanup is explicit when the environment requires it.

Common Mistakes

  • Claiming that Playwright waits for everything without explaining actionability and outcome assertions.
  • Using generated CSS classes, long XPath expressions, first(), or nth() as default locator strategies.
  • Forgetting await on goto, click, fill, or assertions.
  • Performing actions without verifying a meaningful result.
  • Adding waitForTimeout to solve every asynchronous update.
  • Sharing one page, account mutation, or data record across parallel tests.
  • Putting real credentials or storage-state secrets in source control.
  • Calling every failure a product bug before checking test data and environment.
  • Adding retries or long timeouts before reading the first failure evidence.
  • Describing tools without a real example from practice.
  • Overengineering a short coding exercise with unnecessary abstractions.
  • Pretending to have senior architecture ownership instead of explaining actual contributions.

Conclusion

For Playwright interview questions 1 years experience candidates should master the execution layer: isolated tests, semantic Locators, awaited actions, web-first assertions, deterministic data, and evidence-based debugging. Clear reasoning around a small correct test is more valuable than an impressive list of APIs.

Build a compact practice project, break it intentionally, inspect traces, and rehearse the model answers in your own words. Bring one honest defect story and one stability story. That combination shows both automation fundamentals and the QA judgment expected after a year of hands-on work.

Interview Questions and Answers

What is Playwright and what does Playwright Test add?

Playwright is a browser automation library for Chromium, Firefox, and WebKit. Playwright Test adds the runner, isolated fixtures, assertions, projects, retries, reporters, and parallel execution. I use the library through the runner for maintainable end-to-end tests.

What is the difference between a BrowserContext and a Page?

A BrowserContext is an isolated browser session with its own cookies and storage. A Page is a browser tab inside that context. Separate contexts help tests remain independent.

Why are Locators preferred in Playwright?

Locators describe how to find an element and resolve when used, so they handle many rerenders better than storing a node reference. They integrate with actionability and retrying assertions. I prefer user-facing role and label contracts.

Explain Playwright auto-waiting.

Playwright waits for relevant actionability checks before an action. A click normally needs a target that is visible, stable, enabled, and able to receive events. I still assert the resulting business state because actionability does not prove success.

Why should you avoid fixed waits?

A fixed wait measures elapsed time rather than readiness. It slows fast executions and remains unreliable on slower ones. I use a web-first assertion or a targeted event or response wait tied to the behavior.

How do you fix a locator matching multiple elements?

I inspect the matches and add a meaningful accessible name, parent scope, filter, or stable test id. I avoid selecting first unless first position is actually the requirement. Strictness helps expose unclear tests.

How do you verify a successful click?

I assert the user-visible or system outcome, such as a URL, heading, dialog, status, value, or API-backed state. The exact assertion comes from the requirement. The absence of a click error alone is not proof.

What is a fixture in Playwright Test?

A fixture provides a dependency to a test and manages its lifecycle. page and request are built-in fixtures. Custom fixtures can provide prepared components or API clients with controlled setup and teardown.

How do you debug a Playwright timeout?

I read the action log to see what condition timed out, reproduce the focused test, and inspect trace evidence. I check the locator, target state, overlays, data, network, and environment before changing timeouts. A longer timeout is not my first fix.

How do you keep tests parallel-safe?

Tests use isolated contexts and unique or independently controlled data. They do not depend on order or mutate one shared account. Any required cleanup targets only data owned by that test.

How do you test a new tab?

I start waiting for the context page event before clicking the link, then await the new Page and assert its URL or content. Setting the wait first prevents a race with a fast event. I keep assertions on the correct Page object.

How do you store credentials for tests?

I use runtime secrets or environment variables and never commit real credentials. If storage state is reused, I treat it as sensitive and exclude it from source control. Test accounts should have limited permissions.

What is the difference between toBeVisible and isVisible?

toBeVisible is a web-first assertion that retries until the expected condition or timeout. isVisible returns the current boolean state and does not wait for an eventual change. For an expected UI result, I normally choose toBeVisible.

What would you include in a junior Playwright project?

I would include clear specs, configuration, stable locators, controlled data, positive and negative tests, and trace collection for failures. I would add concise run instructions and keep abstractions proportional to repetition. Every test would assert a meaningful outcome.

Frequently Asked Questions

What Playwright topics should a one-year QA engineer prepare?

Prepare Browser, BrowserContext, Page, Locators, actions, web-first assertions, auto-waiting, fixtures, configuration, basic network waits, and trace-based debugging. Also practice testing fundamentals and a short TypeScript exercise.

Are Playwright coding questions asked for one year of experience?

Yes, many interviews include a small login, form, table, popup, or validation task. Interviewers usually value correct awaits, stable locators, meaningful assertions, and explanation more than elaborate framework patterns.

How many Playwright APIs should a junior candidate memorize?

There is no useful fixed number. Know the common workflows and understand how to find the right API, but focus on mental models, actionability, Locators, assertions, isolation, and debugging rather than method lists.

Should a one-year candidate know Playwright fixtures?

Yes, understand built-in fixtures such as page and request, plus the purpose of setup and teardown. You do not need to claim complex fixture architecture, but you should explain lifecycle and why fixtures are safer than shared mutable globals.

How should I answer a Playwright question I do not know?

State what you know, avoid inventing an API, and explain how you would verify the official documentation or create a small reproduction. Connect the unknown detail to a concept you understand and keep the answer honest.

Is TypeScript required for Playwright interviews?

It depends on the role, but TypeScript is common and worth practicing. Be comfortable with async and await, functions, objects, arrays, types, regular expressions, imports, and basic error handling.

What project should I show for a junior Playwright interview?

Show a small clean suite with stable locators, controlled data, positive and negative scenarios, configuration, traces on retry, and clear run instructions. Be prepared to explain every decision and one improvement you made after a failure.

Related Guides