toplenboren / playwright-playground

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hi!

This repository is a small playground for playwright tests

You basically want to learn to do three things:

  1. Generate tests using code generation

  2. Learn how to store credentials safely

  3. Learn how to launch tests


Pre-requisites:

  1. Install node.js
  2. Install yarn
  3. Install dependencies: run yarn in terminal from the root of this project

Tests generation:

Re: https://playwright.dev/docs/codegen-intro

  1. Don't forget about Pre-requisites

  2. Launch test generation UI:

    npx playwright codegen <url>

    This command will open up a window with website specified in <url> argument. You will test this <url>

    Example: npx playwright codegen condo.d.doma.ai

    Example: npx playwright codegen v1.doma.ai

  3. Click some stuff:

    Screenshot 2023-12-04 at 16.19.23.png

    On the right side you are seeing the test code, on the left you are seeing opened website. Now just click some stuff within left window and see how code is written for you!

  4. Don't forget about Assertions

    Screenshot 2023-12-04 at 16.22.30.png

  5. Copy your first test to the ./tests folder

    From PlayWright inspector:

    Screenshot 2023-12-04 at 16.23.23.png

    To code editor

    Screenshot 2023-12-04 at 16.25.48.png

  6. We have generated first test. Inspect test code to learn what it does and go to the Running tests section to learn how to run these tests

Running tests

Re: https://playwright.dev/docs/running-tests

  1. Just use this command:

    yarn playwright test

    Screenshot 2023-12-04 at 16.32.25.png

Writing tests --> Further topics

Re: https://playwright.dev/docs/writing-tests

How to authenticate?

About


Languages

Language:JavaScript 100.0%