Developer friendly load testing framework
Project description
har2locust
Creating a locust file from scratch is sometimes hard. Don't you wish you could just generate it automatically from a browser session?
Well, now you can!
When browsing the web with the Developer Tools open you can record the Network Activities (requests perform by your browser & responses you get from servers). Then you can export all these data into an HAR file (Http ARchive).
Here's an example of har2locust's output
har2locust builds upon har2py, modified to generate a locustfile instead of a basic Python file and extended to support plugins.
Note: It is currently in early beta. It mostly works, but there may be changes to behaviour and interface without notice. If you encounter an issue, PRs are very welcome.
Also, dont expect that the generated file will always work out of the box. You'll need to add response validations to ensure the quality of your test, and perhaps parametrize dynamic data like usernames.
Installation
pip install har2locust
This will also install locust and locust-plugins, because they are needed to run the generated locustfiles.
Usage
-
Navigate the web with your browser while recording your activity. Then save the data in HAR file. Here is an example with Chrome Devs Tools
-
Run
har2locust myharfile.har > locustfile.py
> har2locust --help
usage: har2locust [-h] [-t TEMPLATE] [--plugins PLUGINS] [--resource-types RESOURCE_TYPES]
[--version] [--loglevel LOGLEVEL]
input
positional arguments:
input har input file
options:
-h, --help show this help message and exit
-t TEMPLATE, --template TEMPLATE
jinja2 template used to generate locustfile. Defaults to locust.jinja2. Will
check current directory/relative paths first and har2locust built-ins second
--plugins PLUGINS Comma separated list of extra python files to source, containing decorated
methods for processing the har file.
--resource-types RESOURCE_TYPES
Commas separated list of resource types to be included in the locustfile.
Supported type are `xhr`, `script`, `stylesheet`, `image`, `font`,
`document`, `other`. Defaults to xhr,document,other.
--version, -V show program's version number and exit
--loglevel LOGLEVEL, -L LOGLEVEL
Example usage: har2locust myrecording.har > locustfile
Parameters can also be set using environment variables or config files (har2locust.conf
or ~/.har2locust.conf) For details, see https://goo.gl/R74nmi
-
You can define "plugins" to process your input and add custom output. The built in plugins (e.g. rest.py) are used by default, and also serve as examples for how to make your own.
-
Those built in plugins also read two files: .urlignore and .headerignore (from your current directory). Populate them with regexes to filter any unwanted requests or headers from your recordings. Some headers are always ignored (cookie, content-length and chrome's "fake" headers) Here are some examples: .urlignore, .headerignore
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file har2locust-0.2.4.tar.gz
.
File metadata
- Download URL: har2locust-0.2.4.tar.gz
- Upload date:
- Size: 25.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 043fb017552c82d1e98a8df11a91aee17d0d06fc3183666c9058fbfea87eaa62 |
|
MD5 | 4a6f9cec45e76f7feb7b033b0f833c95 |
|
BLAKE2b-256 | c75806022e9dbde7cb694c39e03bc16ad233f3068b65a4b5f6c2e483cf50abe8 |
Provenance
File details
Details for the file har2locust-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: har2locust-0.2.4-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1edfdf692ab4370de321eea2c534d8d65c380e2fffb550323bd8ef4e0bea9f4a |
|
MD5 | d5e10944469b71f6272091b1c6cb7827 |
|
BLAKE2b-256 | 02664acc55d019301bfbb27b7d24d341abc164437524138e2ca976ac3ce4cab8 |