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.
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-
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
When the test script and BrowserStackLocal binary connection do not use the same local identifier
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With