Skip to content
Tutorials Center
My learning

Topics

Cypress and Playwright Tutorial

Learn Cypress and Playwright step by step: 35 lessons in 11 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What End-to-End Testing Is Learn what an end-to-end browser test does, how it differs from unit tests, how a test drives a page, and where Cypress and Playwright fit in.
  2. 2 Testing Strategy and the Test Pyramid Decide what to test end to end and what to leave to unit and component tests, using the test pyramid, critical user journeys and a cost-versus-confidence score.
  3. 3 Cypress vs Playwright Compare Cypress and Playwright: in-browser runner versus out-of-process protocol, languages, browsers, speed, tabs, iframes and ecosystem, and how to choose.
  4. 4 Your First Cypress Test Install Cypress, open the runner, learn the folder layout and write your first test with cy.visit, cy.get, cy.contains and should, with retrying assertions.
  5. 5 Your First Playwright Test Create a Playwright project with npm init playwright, read playwright.config, write a test with page.goto and expect, run the CLI and open the HTML report.

Finding Elements

  1. 6 Selecting Elements in Cypress Find elements in Cypress with cy.get, cy.contains, find, within, eq, first, parent and data-cy attributes, and learn how subjects, chaining and scoping work.
  2. 7 Locators in Playwright Learn Playwright locators: getByRole, getByLabel, getByText, getByTestId, filter, nth, chaining and strict mode, with a runnable model of how they find elements.
  3. 8 Writing Selectors That Do Not Break Choose selectors that survive redesigns: test ids, accessible roles and labels, and what to avoid (CSS classes, XPath, positions), with a brittleness rater.

Actions and Assertions

  1. 9 Clicking, Typing and Other Actions Learn the action commands in Cypress and Playwright - click, type, fill, check, select, hover, drag and keyboard - plus actionability and when force is a bad idea.
  2. 10 Assertions That Retry How should and web-first expect assertions retry until they pass, when plain expect does not, and how to use soft assertions, polling and timeouts correctly.
  3. 11 Forms, Uploads and Downloads Test forms end to end in Cypress and Playwright: filling fields, validation messages, radios, dates, file uploads with selectFile and setInputFiles, and downloads.
  4. 12 Iframes, New Tabs and Dialogs Test embedded iframes, popups, new tabs, alert and confirm dialogs and shadow DOM in Cypress and Playwright, and learn where each tool has limits.

Async, Waiting and Flakiness

  1. 13 How Cypress Commands Really Work Understand the Cypress command queue: why cy commands do not return values, how subjects flow through chains, and how then, as and wrap fix common bugs.
  2. 14 Auto-Waiting in Playwright Learn how Playwright waits for you: actionability checks, async and await, waitFor, waitForURL, waitForResponse, and why waitForTimeout is a last resort.
  3. 15 Finding and Fixing Flaky Tests Learn why end-to-end tests become flaky, how to reproduce them with repeat runs, when retries help or hide problems, and how to fix timing and shared-state bugs.

Network and Data

  1. 16 Intercepting and Mocking Network Requests Learn to intercept network requests with cy.intercept and page.route: stub responses, simulate errors and slow replies, and wait for requests in your tests.
  2. 17 Test Data and Logging In Fast Seed and reset test data through APIs, skip repeated UI logins with cy.session and Playwright storageState, and keep test secrets out of your repository.
  3. 18 Testing APIs Directly Test HTTP APIs without a browser: cy.request and the Playwright request fixture, assertions on status, headers and body, schema checks and API plus UI combos.

Structure and Maintainability

  1. 19 Hooks, Fixtures and Custom Commands Reuse setup and teardown in browser tests: Cypress hooks and custom commands, Playwright fixtures, test.step and tags, with a runnable fixture engine.
  2. 20 Page Objects and Better Test Structure Structure browser tests with page objects, component objects and app actions, and learn when abstraction helps and when it only gets in the way.
  3. 21 Configuration and Environments Configure Cypress and Playwright: baseUrl, environment variables, projects, timeouts and retries, and run the same tests against local, staging or CI.

Debugging and Reports

  1. 22 Debugging Failing Tests Find out why a browser test fails: Cypress time travel and cy.pause, Playwright UI mode, inspector and codegen, screenshots, and how to read errors.
  2. 23 Traces, Videos and Reports Capture evidence from test runs: Playwright traces, videos and screenshots, Cypress screenshots and Cloud, plus HTML and JUnit reports for your team and CI.

Beyond the Basics

  1. 24 Cross-Browser and Mobile Testing Run browser tests on Chromium, Firefox and WebKit, emulate phones, set viewports, geolocation and permissions, and plan a sensible test matrix.
  2. 25 Visual and Accessibility Testing Catch layout regressions and accessibility bugs automatically: screenshot baselines, toHaveScreenshot, axe-core checks and ARIA snapshots, with runnable stand-ins.
  3. 26 Component Testing Mount one UI component in a real browser and test it in isolation: Cypress component testing, Playwright experimental component tests, and when to prefer e2e.

CI and Scale

  1. 27 Running Tests in CI Run browser tests on every push: GitHub Actions workflows for Playwright and Cypress, installing browsers, Docker images, artifacts, caching and secrets.
  2. 28 Parallel Runs, Sharding and Speed Make browser test suites finish sooner: Playwright workers, fullyParallel and --shard, Cypress parallelization, balancing by duration and cutting test time.

Projects

  1. 29 Project: Test a Login Flow Build a complete test plan for a login page in Cypress and Playwright: valid and invalid logins, validation, redirects and fast session reuse, side by side.
  2. 30 Project: Test a Todo App Write a maintainable test suite for a todo app in Cypress and Playwright: add, complete, filter, delete, persistence, a page object and count assertions.
  3. 31 Project: Test a Shopping Cart and Checkout Test a cart and checkout end to end: stub the catalog API, check totals and coupons in cents, cover error states, and keep test data under control.
  4. 32 Project: Combine API Setup with UI Checks Build a fast, reliable suite: create test data through an API, verify it in the browser, clean up afterwards, and share setup with fixtures.

Practice and Review

  1. 33 Exercises with Solutions Twelve graded exercises on selectors, assertions, intercepts, structure and flaky tests, each with a worked solution and runnable logic checks.
  2. 34 Interview Questions Prepare for browser-testing interviews with 36 questions and short answers on concepts, waiting, selectors, network, CI, and Cypress versus Playwright.
  3. 35 Cheat Sheet A side-by-side cheat sheet of Cypress and Playwright commands for visiting, finding, acting, asserting, network stubbing, configuration and the CLI.