Code Monkey home page Code Monkey logo

playwright-artillery-ui-load-testing's Introduction

UI Load Testing

This repository gives the opportunity for quick UI load testing. It lets you record a usage scenario in the browser as a Playwright Test, transforms it for easier modifications, to then execute a Artillery Load Test. It is supposed to easily create load test scripts, that can be used in external projects in a more complex setup. The goal is the reduction of manual effort by creating the scripts.

Components:

Installation

Prerequisite: Installed NodeJS

npm install

Usage

1. Generate Playwright Test

Start the Playwright Code Generator with the URL of the interested website.

Default Code Generator:

npx playwright codegen https://www.google.com/

Custom Code Generator:

Check the playwright-codegen.js and adjust the configuration on top, then run:

npm run codegen

Copy the generated code into one or more .js files in the 1-generated-code directory. The content can include the full Test Runner content or just the function body lines.

Playwright Codegen

2. Transform generated Code

The generated code must be modified for a reliable load test. Run the following command to transform all generated files from the 1-generated-code directory and save them to 2-transformed-code:

npm run transform

The script will transform all script lines depending on the content. It will store all interaction elements in variables, to make the load test easier to edit. In addition, it adds safety checks for visible elements and only the safety for only one additional frame when select a frame locator. The code-transformer.js can be edited for more custom code. Keep in mind, to rename modified files if the transformer should not overwrite them in the future.

Manual Modifications:

The default version of the code-transformer.js adds too many lines of code, to validate the state of the current test. Before using the transformed script, a manual validation is recommended with following suggested changes:

  1. Check if the Page URL is available.
  2. The check for only one frame can be reduced to once before the dialog interaction.
  3. Check if all selectors for dialogs are build for the first visible dialog.
  4. Visibility is checked for all elements and can be adjusted with custom timeout values.
  5. Validate selectors for the elements.

To debug the generated code, it can be pasted into the playwright-codegen.js sections before or after the breakpoint. The code generator has the functionality like a debugger to step over instructions.

3. Select Usage Scenario

After generating the transformed scripts (and verifying them), select a script as usage scenario via the command line:

npm run select

Answer the CLI, and it will save the selected scenario to 3-scenario for the artillery execution.

4. Run Artillery Script

Adjust artillery-script.yml with custom configuration and run it:

npm run load

For another a ramp-up load test the artillery-rampup.yml can be executed:

npm run rampup

Both will run the code of the selected scenario for virtual users.

References

playwright-artillery-ui-load-testing's People

Contributors

felixsteinke avatar

Stargazers

 avatar  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.