Code Monkey home page Code Monkey logo

playwright's Introduction

NPM Packages

Use Script
PNPM Package npm i -g pnpm For efficient package manager
add tsconfig pnpm tsc --init
tsup pnpm add tsup -D bundle library
noUncheckedIndexedAccess noEmit - tru change in tsconfig
package.json tsup framework --format cjs, esm --dts
to build pnpm run build
Changeset pnpm add -D @changesets/cli

ref: https://www.youtube.com/watch?v=eh89VE3Mk5g

Playwright Guide

Installation

Use Script
Installation npm init playwright@latest
Runs the end-to-end tests npx playwright test
Starts the interactive UI mode. npx playwright test --ui
trace on npx playwright test --trace on
Runs the tests only on Desktop Chrome. npx playwright test --project=chromium
Runs the tests in a specific file. npx playwright test example
Runs the tests in debug mode. npx playwright test --debug
Auto generate tests with Codegen npx playwright codegen
Show Report npx playwright show-report
Open Playwright Inspector npx playwright open
Generate Allure reporting npx allure generate ./allure-results --clean
Open Allure report npx allure open ./allure-report/
To Run tests in local TEST_ENV=local npx playwright test
To Run a specfic test npx playwright test -g "test name"

Running tests using env variable : https://medium.com/@irfan17sat/configuring-multiple-environments-in-playwright-67e402c1c627

Automation Testing Principles : https://testingconsultancy-my.sharepoint.com/:w:/g/personal/aadhith_bose_ttcglobal_com/EW6TZYI_XhVLu2b1MFb-Mk4BInbKTyKlBwifFnGdh-RmPQ?e=sNZvUW

Page Objects

Name Description
By Tag Name page.locator('input')
By ID page.locator('#id')
By Class Value page.locator('.class value')
By Attribute page.locator('[placeholder="Email"]')
By Full Class Value page.locator('[class="full static shape rectangle"]')
Combine page.locator('#id').locator(.class)
Combine page.locator('#id').getByRole('button, {name:"Sign in"}')
By Xpath page.locator('//xpath')
By Partial text page.locator(':text("Email")')
By Exact text page.locator(':text-is("Email here")')

=============== Notes

Assertion

await expect(locator).not.toBeVisible(); or await expect(locator).toBeHidden();

===========================================================

To update screenshots npx playwright test --update-snapshots

To run in UI mode npx playwright test --ui Retries npx playwright test --update-snapshots or const config: PlaywrightTestConfig = { retries: 3, };

To Show Report npx playwright show-report

============================================================ Getting Started Initialize playwright npm init playwright@latest

Add a test file mkdir tests && touch tests/search.test.ts

Head / Headless mode npx playwright test --headed or add in config file

To Skip a particular tests Add in the test file test.skip(browserName === 'webkit', 'Skipped in Safari, due to known issue');

playwright's People

Contributors

fasteningcode avatar inozai avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.