How do I load test a website with login credentials?

By Mark. In Tutorials. On 2016-11-04

If you're expecting people to come to your website or application and log in with a username and password, then you absolutely need to prepare for that in your load testing.

Load Impact supports both basic HTTP authentication and HTTP POST operations, as well as HTTPS. This means we support most common methods for logging into sites.

Login using HTTP POST

Many sites let users login by entering their username and password in input fields of a form that is then POST:ed to the web server.

Load Impact supports HTTP POST operations, which means you may edit your load script and provide the login credentials (username/password) in a POST operation.

When the server gets the right login credentials through this POST operation, it sets a session cookie in your browser. The session cookie is used for all future communications with the web server, authenticating you as a logged-in user.

Load Impact automatically sets cookies when asked to by the server, so accessing pages as a logged-in user works fine if you just make sure your load script performs that initial POST operation.

More information:

Basic HTTP Authentication

Basic HTTP Authentication is a method where the server will only honor requests if they contain a special HTTP header (the “Authorization:” header) where the client has to place the login credentials (username and password) that are to be used to gain access to the site or page.

Load Impact supports Basic HTTP Authentication by the use of URLs in this format:

If you use URLs of that format, include the username and password to be used when accessing the site/page and requests will automatically get the “Authorization:” header with the correct data in them.

We also allow HTTP request headers to be specified for each transaction, so it’s possible to create the data for the “Authorization:” header in the load script code and then add the header to each request.

  headers={ ["Authorization"]= 'Basic ' + base64.encode(username + ':' + password) }

And if you’re looking for some more helpful hints, check out our Support documentation on these related topics.