Base URL

Learn how to run your test in different environments with different base URLs

Have you ever wondered how to run the same test with different URLs?
Did you want to run your suite in different environments - test, staging and possibly production and did not know what would be the best way to do it?
You came to the right place.

Running remotely

Typically, you record your tests on the development/test environment and then you want to run your tests on other environments as well.

We provide a base URL parameter that can be used in all remote runs methods.
Here's a list of components you can use to send a different base URL:

Base URL Parameter

In every custom action/validation, you can access your base URL using the "BASE_URL" parameter. e.g. console.log("Base URL:" + BASE_URL)

Add Base URL Parameter to Navigation Step

To add the Base URL parameter to a Navigation Step:

  1. Hover over the + or Arrow icon where you want to add a new Navigation Step and click the Testim predefined steps button.
304304
  1. Search for Add navigation action and click it.
404404
  1. Input the URL using the BASE_URL parameter, followed by remaining URL path.
690690

Testim will save the Navigation Step with your dynamic URL.

17981798

When the step runs, Testim will navigate to the Base URL used during setup. In the example below, Testim will navigate to http://demo.testim.io/login when the step runs.

674674

Overriding base URL and navigation hosts

Base URL

In setup step in a test, you sometimes pass the base URL with a path to a specific location in your application. In that case, when passing a different base URL to the test, navigation will be relative to the base URL sent.

Example: If base Url in setup is http://staging.com/login , when passing this base Url parameter in runtime: http://preprod.com , the actual navigation in run time will be to : http://preprod.com/login.

Navigation steps

In navigation steps, you sometimes navigate to a URL with the same host as in your setup step. In that case, when passing a different base URL to the test, navigation will be relative to the base URL sent.

Example: If base Url in setup is http://staging.com/ and the URL in navigation step is http://staging.com/ca . When passing this base Url parameter in runtime: http://preprod.com/ , the actual navigation in run time will be to : http://preprod.com/ca.

Rerun with the same parameters

This allows you to rerun locally, a test that was run remotely with different base URL. It will also use the same parameters as run by the remote run.
Read more here.