Skip to main content
Transform your testing process with: Real Device Features, Company-wide Licences, & Test Observability

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.

Select your integration method

  • BrowserStack SDK (Recommended)
    Plug-n-play solution that takes care of all the integration steps for you
  • Legacy integration
    Start and stop the BrowserStack Local tunnel within your test suite manually

BrowserStack SDK is the recommended method for running JUnit tests on BrowserStack.

Learn the benefits of using BrowserStack SDK

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

Integration step With BrowserStack SDK With manual integration
Connect to CDP Endpoint to run tests on BrowserStack Yes Via the browserstack.yml config file Changes Requires code changes to change the CDP Endpoint
Integrate with BrowserStack Local Yes Via the browserstack.yml config file Changes Requires code changes in test suite
Send test context to BrowserStack for reporting Yes Via the browserstack.yml config file Changes Requires additional code to be added in the test suite hooks
Use basic cross browser testing parallelization Yes Via the browserstack.yml config file Changes May require code changes depending on the test suite
Use advanced parallelization strategies Yes Via the browserstack.yml config file Changes Requires code changes to support different parallelization strategies

Prerequisites

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 junit-playwright-browserstack repository using the following command:

Copy icon Copy snippet

Compile the project

Compile the source code of the project by running the following command in your terminal/command-line:

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 environment variables.

browserstack.yml
Copy icon Copy snippet

Configuring BrowserStack Local

Ensure that the browserstackLocal parameter is set to true in your browserstack.yml config file.

browserstack.yml
Copy icon Copy snippet

Execute build on BrowserStack

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

Copy icon Copy snippet

View test results

View your tests on the BrowserStack Automate dashboard. To learn more about the dashboard, check the view test results document.

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

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