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.
Prerequisites
- You need to have BrowserStack Username and Access key, which you can find in your account profile. If you do not have an account yet, please sign up for a Free Trial or purchase a plan.
- Node.js v12+ installed on your machine.
- BrowserStack WDIO service is installed in your automation test suite.
Configure BrowserStack Local
Once you install the BrowserStack WDIO service in your project, add browserstack
in the services
array of your configuration file, and set the browserstackLocal
capability to true
, as shown in the following code snippet:
You can now test your private websites on BrowserStack.
Check BrowserStack Local 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 webdriverio-browserstack repository and install dependencies using the following commands:
Set BrowserStack credentials
Set user
and key
in the base.conf.js
configuration file. Skip this step if you have already set credentials as environment variables.
Execute build on BrowserStack
From the root directory of this project, run the following command:
If the test fails, refer to the following section 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. Following are the 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 configuration (.conf.js
) file.
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 redirecting to bs-local.com
. This is a necessary action due to circumventing Safari browser behaviors and limitations. Check out the detailed explanation in this FAQ.
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 configuration .conf.js
file.
After you run your test, visit the Automate dashboard to view your test results.
Advanced use-cases and troubleshooting
For restricted networks and troubleshooting, refer the following articles:
- Configure proxy settings (HTTP, MITM)
- Configure proxy using PAC file
- Troubleshoot BrowserStack Local issues
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
- RESOURCES
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!