Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BrowserStack Error- [browserstack.local] is set to true but local testing through BrowserStack is not connected

While trying to execute a Selenium test on BrowserStack with the capability 'browserstack.local' as 'true' I am getting the following exception-

org.openqa.selenium.WebDriverException: [browserstack.local] is set to true but local testing through BrowserStack is not connected.

If I remove the capability 'browserstack.local' then the test executes, however, it does not access the private network application. I tried to search other online resources around this exception, however, could not find any details.

URL URLObj = new URL("https://" + USERNAME + ":" + KEY + "@hub-cloud.browserstack.com/wd/hub");

DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("device", "iPhone 8 Plus");
caps.setCapability("real_mobile", "true");
caps.setCapability("browserstack.local", "true");

AppiumDriver webDriver = new IOSDriver(URLObj, caps);

The excepted result is that the test should run and the private network application should be accessible. Also, the above exception should not be thrown.

like image 358
Xtraterrestrial Avatar asked Dec 07 '22 12:12

Xtraterrestrial


1 Answers

BrowserStack provides the Local testing feature to test the internal websites which are not accessible publicly. Local testing feature is enabled by setting the capability 'browserstack.local' to the value 'true' and starting the BrowserStackLocal binary.

Have you started the BrowserStackLocal binary? You can start the binary by executing the following command in your command prompt-

BrowserStackLocal.exe --key ACCESS_KEY

The error - '[browserstack.local] is set to true but local testing through BrowserStack is not connected.' usually occurs when the BrowserStackLocal binary is not running.

I can think of the following causes for the error-

  1. When the test script and BrowserStackLocal binary connection do not use the same username and access key. You can verify the username and access key associated with your account here, https://www.browserstack.com/accounts/settings

  2. When the test script and BrowserStackLocal binary connection do not use the same local identifier

  3. When a new BrowserStackLocal binary is invoked with the same parameters and hence the old connection is closed thereby displaying the error
  4. Binary disconnected at your end due to some network connectivity issues

You can make sure that the test script and the BrowserStackLocal binary uses the same access key and the same local identifier, in case, if you are using a Local Identifier for the BrowserStackLocal binary connection. Also, make sure that all the old connections of BrowserStackLocal binary are terminated before starting a new one with the same parameters. Read more on Local testing here, https://www.browserstack.com/local-testing.

like image 126
N3M Avatar answered Feb 05 '23 16:02

N3M