Header Ads

  • Breaking News

    Setup NodeJS playwright and run the first script

    What is Playwright?

    The playwright is a NodeJs-based automation framework. It is developed by Microsoft with the same team which also developed Puppeteer. (Click here to read posts on Puppeteer). It helps to automate the browser with/without headless. It provides additional functionality over Puppeteer like cross-browser support, cross-programming language support, auto wait, default reports, and much more.

    Here is the youtube video where I have discussed, what is playwright? Advantages of the playwright, installation, explained example script, run the first playwright test with and without headless mode. Watch the video and subscribe to the channel. 

    Advantages of Playwright

    • Cross Browser - Supports all chromium-based browsers
    • Cross Platform - Supports all os like Windows, Mac, and Linux. Supports Docker, and CircleCI with headed or headless
    • Cross-Language - Supports most of programing languages like Javascript, Typescript, Java, C#, Python
    • Test Mobile web - allows running automation on the mobile web in Chrome for Android and Safari for ios
    • Auto waits
    • Assertions 
    • Tracing 
    • Browser contexts
    • Codegen - allows generating code automatically 
    • Playwright inspector 
    • Trace viewer 

    how to Install Playwright

    You can install a playwright using npm or yarn. 

    Using NPM - npm init playwright@latest
    Using Yarn - yarn create playwright

    Before this Node and npm should be installed.

    When you install Playwright following files get installed 
    • playwright.config.ts
    • package.json
    • package-lock.json
    • tests/example.spec.ts
    • tests-examples/demo-todo-app.spec.ts
    I have explained these in detail in the Video. 

    Run Playwright tests 

    You can run playwright Tests using "npx playwright test" in headless mode. 
    Run Playwright tests without headless mode (on UI) - npx playwright test --ui

    Get the Playwright's automation run report

    Playwright by default provides HTML report. You need not to configure anything specific for that. If something gets failed it opens the automation report by default else need to open through file or with this command 
    "npx playwright show-report"

    I have explained the report in detail in the youtube video I have shared above. 

    If you have any doubts or suggestions feel free to reach out on social media. Follow Us on RedditFacebook, and Twitter. Don't forget to subscribe to the channel -> Youtube channel. Thank You

    All Playwright Tutorial Posts -

    No comments

    Post Top Ad

    Post Bottom Ad