0

I'm trying to run browserstack behind the firewall.

I tried to run this command on terminal:

RK$ ./BrowserStackLocal --key <key> --force-local


BrowserStackLocal v7.0

You can now access your local server(s) in our remote browser.

Press Ctrl-C to exit

I opened another terminal and I ran the command

npm run test:functional:cr:mobile

I get the following error:

  1) Run sample test flow page:
     Uncaught WebDriverError: [browserstack.local] is set to true but local testing through BrowserStack is not connected.

This is my config.js

'use strict'
import webdriver from 'selenium-webdriver'
let driver
module.exports = {
    getDriverConfiguration: function (testTitle, browserName) {
            var capabilities = {
                'browserName': process.env.BROWSER || 'Chrome',
                'realMobile': 'true',
                'os': 'android',
                'deviceName': process.env.DEVICE || 'Samsung Galaxy S8',
                'browserstack.user': 'USER',
                'browserstack.key': 'KEY',
                'browserstack.debug': 'true',
                'build': 'Build for mobile testing',
                'browserstack.local' : 'true',
                'browserstack.localIdentifier' : 'Test123'
            }
            driver = new webdriver.Builder().withCapabilities(capabilities).usingServer('http://hub-cloud.browserstack.com/wd/hub').build()
            driver.manage().deleteAllCookies()
            return driver
    }
}

I enabled browserstack.local to true but I still get this error.

Not sure where I'm going wrong.

Please kindly help.

TechnoCorner
  • 4,879
  • 10
  • 43
  • 81

1 Answers1

0

The error [browserstack.local] is set to true but local testing through BrowserStack is not connected. is returned if your BrowserStackLocal connection (the one you established using ./BrowserStackLocal --key --force-local) is disconnected.

I would suggest you use the following approach instead, to avoid the additional step and easily manage your local testing connection:

npm install browserstack-local

Once you have installed the browserstack-local module, use the following code snippet as reference to modify your code and start browserstack-local from your code itself(before the line driver = new webdriver.Builder().withCapabilities(capabilities).usingServer('http://hub-cloud.browserstack.com/wd/hub').build()), instead of starting it from a separate terminal window:

var browserstack = require('browserstack-local');

//creates an instance of Local
var bs_local = new browserstack.Local();

// replace <browserstack-accesskey> with your key. You can also set an environment variable - "BROWSERSTACK_ACCESS_KEY".
var bs_local_args = { 'key': '<browserstack-accesskey>', 'forceLocal': 'true' };

// starts the Local instance with the required arguments
bs_local.start(bs_local_args, function() {
  console.log("Started BrowserStackLocal");
});

// check if BrowserStack local instance is running
console.log(bs_local.isRunning());

// stop the Local instance
bs_local.stop(function() {
  console.log("Stopped BrowserStackLocal");
});
BountyHunter
  • 1,413
  • 21
  • 35