Playwright
Automated Web Testing and Monitoring with Playwright
Last updated
Automated Web Testing and Monitoring with Playwright
Last updated
Install Playwright using yarn, npm, or via VS Code as shown below :
Using yarn:
Using npm:
You will be given the option to choose between Typescript and Javascript. By default, it will be Typescript.
The name of your Test folder will either be 'tests' or 'e2e'.
You can open an already existing file to understand the structure (Example: spec.ts).
Using VS Code:
Install the extension called 'Playwright Test for VSCode'.
Open the Command Palette and type 'Install Playwright' as shown in the reference below.
You will be asked to choose the browsers you would like to run your tests on. Type the following command in the terminal to open Playwright Inspector and Chromium (or, another web driver).
Type the URL of the application you would like to test in the browser and click ‘Record’ on the Playwright Inspector.
Go back to the application and perform a few actions to create scripts.
Copy the code and paste it to the file created under the extension '.spec.ts'.
Type the following command in the terminal to run the code:
To run all tests,
To run a specific test (say, sample.spec.ts),
To run a specific test (say, sample.spec.ts) in chromium,
To view the HTML report of the test result,
7. Integrate with PerfAgents
To take screenshots, add this line of code:
Screen recording is by default turned on for all tests in Playwright
To include multiple tests inside a single file, create each test as different Playwright "test" functions
Make sure to save the file using the ".spec.ts" or ".spec.js" extension. Example: "sample.spec.ts"
By performing the above-mentioned steps, you will obtain validated test cases that can be uploaded during the 'Install' step, and by clicking on 'Next' it goes to the next step i.e., 'Device Profile' where the user have to choose the type of device. Next is the Frequency page.
Sequence monitoring now supports access to custom variables inside of test files as environmental variables
To use custom variables inside JavaScript or typescript fie