Skip to main content

Setting Login Credentials

Testpilot uses environment variables to securely manage your login credentials:
These credentials will be used whenever a test requires authentication. You can set these in your shell profile, CI environment, or just before running your tests. You can also use the secret manager of your choice to set these credentials before running Testpilot

Configuring Custom Environment Variables For Login

Alternatively, you can also use custom env-vars of your own choosing by specifying them in the pilot file:

Configuring Login URL

To tell Testpilot where to log in, add a login.url field to your pilot file:
The login.url parameter tells Testpilot where to perform the authentication before running your tests.

How Authentication Works For Websites

When you provide both a login URL and credentials, Testpilot will:
  1. Launch a browser session
  2. Navigate to the login URL
  3. Automatically detect and fill in username and password fields
  4. Submit the login form
  5. Verify successful authentication
  6. Reuse this authenticated session for all your test cases
This means you only authenticate once, and all your test cases benefit from the same authenticated session, saving time and reducing flakiness.

Example: Testing Authenticated Features in a Website

Here’s a complete example of testing features that require authentication:
In this example, Testpilot will log in once, then run both test cases using the same authenticated session. By properly configuring login credentials and URL, you can easily test authenticated sections of your application without repeatedly handling the login process in each test case.

Example: Testing Login Flow for a mobile app

For mobile apps, the login steps have to be more explicitly specified and tested, notably as done in step 2 below.
If you are using a custom env-var for the password (i.e. other than TESTPILOT_PASSWORD) then you are encouraged to specify the top-level login.password field as well. This helps Testpilot handle the password string literal more securely.