Developer friendly load testing framework
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! har2locust converts your browser recordings (HAR files) into locust files.
Here's an example of a generated file.
At its core har2locust uses a jinja2 template to define the output. You can easily change that to customize your output, or you can go even further and use the plugin system to make any kind of changes to the processing/output.
pip install har2locust
This will also install locust and locust-plugins, because they are needed to run the generated locustfiles.
Navigate the web with your browser while recording your activity. Then export the recording into a HAR file. Here is an example with Chrome Devs Tools
har2locust myharfile.har > locustfile.py
> har2locust --help usage: har2locust [-h] [-t TEMPLATE] [--plugins PLUGINS] [--disable-plugins DISABLE_PLUGINS] [--resource-types RESOURCE_TYPES] [--version] [--loglevel LOGLEVEL] input positional arguments: input har input file optional arguments: -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. --disable-plugins DISABLE_PLUGINS Temporarily disable default plugins. Specified by comma separated list of default plugin python files to source. --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 usages: har2locust myrecording.har myplugin1.py > locustfile har2locust --disable-plugins=rest.py myrecording.har myplugin1.py > locustfile Parameters can also be set using environment variables or config files (har2locust.conf or ~/.har2locust.conf) For details, see https://goo.gl/R74nmi
Filter your recording using the files
.headerignore(read 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
Use the plugin system for more advanced processing.
Edit the file manually as needed.
har2locust builds upon har2py, modified to generate a locustfile instead of a basic Python file and extended to support plugins.
har2locust is very new, and before 1.0 there may be changes to interfaces without notice. If you encounter an issue, PRs are very welcome.
Also, dont expect that the generated file will always be very useful out of the box. You'll want to add response validations to ensure the quality of your test, and perhaps parametrize dynamic data like usernames.
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for har2locust-0.8.0-py3-none-any.whl