Run Tests in Dev Environments

Learn how to test localhost and staging websites without publicly hosting them.

Local Testing

BrowserStack enables you to run automated tests on your internal development environments, on localhost, staging setups or from behind a corporate firewall. This feature is called Local Testing.

Local Testing establishes a secure connection between your machine and the BrowserStack cloud. Once you set up Local Testing, all your private URLs work out of the box, including HTTPS URLs and those behind a proxy or firewall.

Setting up Local testing

First, you will need to download the Local binary. Choose one based on the operating system of your machine - OS X | Linux (32-bit) | Linux (64-bit) | Windows

Next, unzip the file that you downloaded, and establish the Local testing connection using the following command:

Command Line
BrowserStackLocal --key YOUR_ACCESS_KEY

Once the connection is established, you can use local key in the connection_settings option to specify the Local connection settings, like this:

browserstack.json
{
  "connection_settings": {
    "local": true
  }
}

Alternatively, you can set the environment variable BROWSERSTACK_LOCAL to true. Note that the environment variable will override the options in your browserstack.json.

Using multiple Local connections

If you are already using Local for running your Selenium or JS tests, establishing another Local testing connection disconnects an already existing connection established using the key.

Instead, you can use the --local-identifier option while establishing the Local connection, and use the local_identifier key to mention the same.

Example:

Establish the Local testing connection

Command Line
BrowserStackLocal --key YOUR_ACCESS_KEY --local-identifier CypressLocalConnection1

And mention the same Local identifier in the configuration file

browserstack.json
{
  "connection_settings": {
    "local": true,
    "local_identifier": "CypressLocalConnection1"
  }
}

Alternatively, you can set the environment variable BROWSERSTACK_LOCAL_IDENTIFIER with the appropriate string you want to use as the identifier for your Local connection. Note that the environment variable will override the options in your browserstack.json.

We're sorry to hear that. Please share your feedback so we can do better






Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback