---
title: "[TEMPLATE]Testing web applications using Playwright"
canonical: "https://docs.getxray.app/space/XRAYCLOUD/74385410/%5BTEMPLATE%5DTesting%20web%20applications%20using%20Playwright"
format: markdown
---
What you'll learn Define tests using Playwright-test Run the test and push the test report to Xray Validate in Jira that the test results are available Source-code for this tutorial code is available in  GiHub Overview Playwright is a recent browser automation tool that provides an alternative to Selenium. Prerequisites For this example we will use  Playwright Test Runner , which in turn is based on  Folio  - a customisable test framework to build higher-level test frameworks using Jest-like assertions. It is still fairly new as pointed in the official documentation: If we want, we can use other runners though (e.g. Jest, AVA, mocha).  We will need: Access to a  demo site  that we aim to test Node.js environment with Playwright and  Playwright Test Runner To start using the  Playwright Test Runner  please follow the  Get Started  documentation. The test consists in validating the login feature (with valid and invalid credentials) of the  demo site , for that we have created a page object that will represent the loginPage plus a configuration file where we have the identifiers that will match the elements in the page And define the test that will assert if the operation is successful or not The  Playwright Test Runner  provides a Jest like way of  describing test scenarios , in here we can see that it uses ' it, describe, expect '. These are simple tests that will validate the login functionality by accessing the  demo site , inserting the username and password (in one test with valid credentials and in another with invalid credentials), clicking the login button and validating if the page returned is the one that matches our expectation. Once the code is implemented (and we will make it fail on purpose on the ' Login with invalid credentials ' test due to missing word, to show the failure reports), it can be executed with the following command: npx folio -p browserName=chromium --reporter=junit,line --test-match=login.spec.ts We define one extra parameter: " browserName " in order to execute the tests only with the chrome browser (chromium), otherwise the default behaviour is to execute the tests for the three available browsers (chromium, firefox and webkit). The results are immediately available in the terminal   In this example, one test has failed and the other one has succeed, the output generated to the terminal is the above one and the correspondent Junit report is as below: We repeated this process for each browser type in order to have the reports generated for each browser. Notes: By default it will execute tests for the 3 browser types available (that is why we are forcing to execute only for one browser) By default all the tests will be executed in headless mode Folio command line will search and execute all tests in the format:  "**/?(*.)+(spec|test).[jt]s"  In order to get the Junit test report please follow this  section Integrating with Xray As we saw in the above example, where we are producing Junit reports with the result of the tests, it is now a matter of importing those results to your Jira instance, this can be done by simply submitting automation results to Xray through the REST API, by using one of the available CI/CD plugins (e.g. for Jenkins) or using the Jira interface to do so. Tips after results are imported, in Jira Tests can be linked to existing requirements/user stories, so you can track the impacts on their coverage. results from multiple builds can be linked to an existing Test Plan, to facilitate the analysis of test result trends across builds. results can be associated with a Test Environment, in case you want to analyze coverage and test results by that environment later on. A Test Environment can be a testing stage (e.g. dev, staging, prepod, prod) or a identifier of the device/application used to interact with the system (e.g. browser, mobile OS). References https://github.com/microsoft/playwright-test/blob/master/README.md https://playwright.dev/ https://github.com/microsoft/folio https://playwright.tech/blog/using-jest-with-playwright