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

Unable to perform Selenium Local testing with BrowserStack

Learn how to resolve connectivity issues when using BrowserStack Local.

Local Testing enables remote browsers and devices from the BrowserStack cloud to access websites hosted on your internal networks, which are otherwise not accessible over the public Internet. Check out the following resources to understand the Local Testing basics with Automate:

Issue

When trying to perform Local Testing with BrowserStack, you may encounter the following error:

browserstack.local is set to true but local testing through BrowserStack is not connected.

Causes

With BrowserStack Automate, you can establish a Local Testing connection in either of the following two ways:

  • Language bindings
  • Command-line interface

The connection method used in combination with one of the following reasons might lead to the exception. Use the following information to identify and resolve your Local issues.

Local connection not established

Resolution/Workaround:

Before you begin troubleshooting, ensure that you understand the Local Testing basics. Check out Getting Started with Local testing to learn about how Local Testing works.

If your method of establishing a local connection is using the BrowserStack Local binary, try the following solutions:

  • In your CI/CD build script, add a condition to grep the following message, and trigger your tests only after the success message appears indicating that the local connection is inititated:
    [SUCCESS] You can now access your local server(s) in our remote browser
    
  • Ensure that the Local binary is running before the session starts. Try running the binary again and run your tests after the following message appears:
    [SUCCESS] You can now access your local server(s) in our remote browser
    
  • Wait a few seconds after starting the Local Binary. Since the connection might take approximately 5 seconds to establish the connection, run your tests after the connection is established.

If your method of establishing a local connection is using language bindings, try the following solutions:

  • Since the connection might take few seconds to establish the connection, you can add an explicit wait duration of a few seconds so that your test scripts run after the Local connection is established.

  • Use a callback function in your script that asserts whether the Local connection has been established before triggering the test scripts.

The following sample Java code snippet shows how the isRunning() callback function can be used.

import com.browserstack.local.Local;
 // Creates an instance of Local
 Local bsLocal = new Local();
 // You can also set an environment variable - "BROWSERSTACK_ACCESS_KEY".
 HashMap<String, String> bsLocalArgs = new HashMap<String, String>();
 bsLocalArgs.put("key", "YOUR_ACCESS_KEY");
 // Starts the Local instance with the required arguments
 bsLocal.start(bsLocalArgs);
 // Check if BrowserStack local instance is running
 
 while(!bsLocal.isRunning()){
   thread.sleep(1000);
 }
 System.out.println(bsLocal.isRunning());

 // Stop the Local instance
 bsLocal.stop();

Local connectivity issues

Check if you are behind a proxy

Resolution/Workaround:

If the website you want to test is behind a proxy, ensure that you set the proxy host and procy port as part of the Local connection using the following command:

Command Line
BrowserStackLocal --key <YOUR_ACCESS_KEY> --local-proxy-host <proxy_host> --local-proxy-port <proxy_port>

Other miscellaneous reasons

The BrowserStack Access Key set in the test script and the BrowserStack Local binary doesn’t match

Resolution/Workaround:

Ensure that the BROWSERSTACK_ACCESS_KEY used in the test script and the BrowserStack Local binary setup is the same.

The Local Identifier in the test script and the BrowserStack Local binary doesn’t match

Resolution/Workaround:

Ensure that the local_identifier used in the test script and the BrowserStack Local binary setup is the same.

Local testing can’t be used together with the IP GeoLocation capability

Resolution/Workaround:

If you have set the geoLocation capability in your test script, ensure that you remove the capability and rerun your test to continue using Local.

Need some help?

If you need additional help, contact our Support team.

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 Check Circle