Developer friendly load testing framework
Project description
har2locust
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). With har2locust you can convert HAR file into valid python code that reproduce the requests perform by your browser.
Here's an example of the auto-generated output
har2locust builds upon har2py, modified to generate a locustfile instead of a basic Python file.
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.
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] [-p PLUGINS] [-f FILTERS] [--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. Default to locust.jinja2. Will check current
directory/relative paths first and har2locust built-ins second
-p PLUGINS, --plugins PLUGINS
Comma separated list of extra python files to source, containing a method decorated with
@ProcessEntries for processing har-entries before generating the locustfile
-f FILTERS, --filters FILTERS
Commas separated list of resource types to be included in the locustfile. Supported type are
`xhr`, `script`, `stylesheet`, `image`, `font`, `document`, `other`. Default to
xhr,document,other.
--version, -V show program's version number and exit
--loglevel LOGLEVEL, -L LOGLEVEL
Example usage: har2locust myrecording.har --plugins myplugin1.py > locustfile.py
-
You can define "plugins" to process your input using the ProcessEntries decorator. The rest.py plugin is used by default, and serves as an example for how to make your own.
-
har2locust also reads 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
Hashes for har2locust-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 504b498115fdaa54f8ae2a2a29c62edbcf89784683196c164720dfbfe891492a |
|
MD5 | 7d4977d0962810959258d0b3a2ec8546 |
|
BLAKE2b-256 | bf3dc61f246f1187014bdf87c6ee27e267410d14f5818cff7a204c67716d660f |