Skip to main content

Test localhost and staging websites that are not publicly accessible

BrowserStack can integrate with test suites pointing to your localhost URL, staging environment, and even websites behind one or more proxies/firewalls. This is done using BrowserStack Local - a tunneling feature that establishes a secure connection between your machine and the BrowserStack Cloud.

Learn the benefits of using BrowserStack SDK

Following are the benefits of using BrowserStack SDK against manual integration process:

Integration Steps BrowserStack SDK Manual Integration / Other Cloud providers
Webdriver changes to run tests on BrowserStack Yes Supported without any code changes Changes Requires code changes to change RemoteWebdriver
Sending test context to BrowserStack for reporting Yes Supported without any code changes Changes Requires code changes in test suite
Integration with BrowserStack Local Yes Supported via config Changes Requires code changes in test suite
Basic cross-browser/device parallelisation Yes Supported via config Changes May require code changes in test suite
Advanced parallelisation strategies* Yes Supported via config Changes May require code / architecture changes in test suite
Time taken to complete integration Time Less than 15 min Time Upto 4 hours*

* Depending on your test framework


Prerequisites

Configuring BrowserStack Local

Once you have installed the BrowserStack SDK, ensure the browserstackLocal property is set to true in your browserstack.yml config file. You can now test your private websites on BrowserStack.

browserstack.yml
Copy icon Copy snippet

Check connectivity

Run this sample test to check if BrowserStack Local is working as expected and can connect to BrowserStack servers.

Clone sample git repository

Clone the sample robot-browserstack repository using the following command:

Copy icon Copy snippet

Set BrowserStack credentials

Set userName and accessKey in the browserstack.yml config file. Skip this step if you have already set credentials as env variables.

browserstack.yml
Copy icon Copy snippet

Execute build on BrowserStack

From the root directory of this project, run the following command:

Copy icon Copy snippet

If the status check fails, refer to the sections below for additional configuration that may be needed.

Additional configuration

BrowserStack Local works out of the box in most cases, but depending on the URL being tested and your network setup, additional configuration may be needed. Here are the most frequently occurring scenarios:

The URL being tested is accessible from the internet but serves different content within your internal network.

This is common with staging environments set up as sub-domains and configured to work only in your private/VPN network. In this case, add the following entry in your browserstack.yml file.

browserstack.yml
Copy icon Copy snippet

The forceLocal capability will resolve all network traffic through the BrowserStack Local tunnel.

Testing on Safari and iOS devices

When testing localhost on Safari desktop browsers and iOS real devices, your automation scripts Get URL / Open URL commands are rewritten to bs-local.com. This is a necessary action due to circumventing Safari browser behaviors and limitations. Read more about it here.

Potential impact on your test scripts

If your application is not honoring relative URLs and explicitly refers to localhost from a config file for example. In this case, we recommend honoring relative URLs in your web application as a best practice; or handling this case as you deem fit.

Bypass invalid certificate browser warnings

To avoid invalid certificate errors while testing on our remote browsers, set the acceptInsecureCerts capability at the root level in your browserstack.yml file.

browserstack.yml
Copy icon Copy snippet

Advanced use-cases and troubleshooting

For restricted networks and troubleshooting, refer the following articles:

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

Is this page helping you?

Yes
No

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!

Talk to an Expert
Download Copy