Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After BrowserStackLocal runner app update wdio fails to run local BrowserStack server #105

Open
dimkin-eu opened this issue Jun 2, 2020 · 3 comments

Comments

@dimkin-eu
Copy link

Environment (please complete the following information):

  • WebdriverIO version: 6.1
  • Mode: [ WDIO Testrunner]
  • If WDIO Testrunner, running sync/async: [ sync ]
  • Node.js version: [v12.16.1]
  • NPM version: [6.14.5]
  • Browser name and version: [Chrome 83]
  • Platform name and version: [macOS Catalina 10.15.5]
  • Additional wdio packages used (if applicable):
    "@wdio/allure-reporter": "6.1.14",
    "@wdio/browserstack-service": "6.1.15",
    "@wdio/cli": "6.1.15",
    "@wdio/dot-reporter": "6.1.14",
    "@wdio/local-runner": "6.1.14",
    "@wdio/mocha-framework": "6.1.14",
    "@wdio/spec-reporter": "6.1.14",
    "@wdio/sync": "6.1.14",

Config of WebdriverIO
common things, apart this

    user: process.env.BROWSERSTACK_USERNAME,
    key: process.env.BROWSERSTACK_ACCESS_KEY,
    capabilities: [
        {
            "bstack:options": {
                "os": "Windows",
                "osVersion": "10",
                "resolution": "1920x1080",
                "networkLogs": "true",
                "video": "false",
                "seleniumVersion": "3.141.59"
            },
            "browserName": "Chrome",
            "goog:chromeOptions": {
                excludeSwitches: ["enable-automation", "load-extension"]
            }
        }
    ],

    services: [["browserstack", { browserstackLocal: true }]],

    onPrepare(config, capabilities) {
        bsLocal = new browserstack.Local();

        return new Promise(function (resolve) {
            bsLocal.start({ "key": process.env.BROWSERSTACK_ACCESS_KEY }, function (error) {
                if (error) {
                    console.log(error);
                } else {
                    resolve();
                }
            });
        });
    },

Describe the bug
BrowserStack dropped old app, and the new app creates problems for running

To Reproduce

  1. install new local testing app https://www.browserstack.com/local-testing/live - this need for manual testing via browser
  2. try to run wdio test using BrowserStack

Expected behavior
test runs

Log

LocalError: Either another browserstack local client is running on your machine or some server is listening on port 45690
    at /Users/.../node_modules/browserstack-local/lib/Local.js:65:20
    at ChildProcess.exithandler (child_process.js:294:7)
    at ChildProcess.emit (events.js:311:20)
    at ChildProcess.EventEmitter.emit (domain.js:482:12)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) {
  name: 'LocalError',
  message: 'Either another browserstack local client is running on your machine or some server is listening on port 45690',
  extra: undefined
}

For a workaround is not enough to uninstall the app or just kill running processes - you need to kill both ( app is pretty smart :) )

 % ps -ax | grep BrowserStackLocal
31261 ??         0:00.01 bash /Applications/BrowserStackLocal.app/Contents/Resources/public/start_binary.sh
31266 ??         0:00.63 BrowserStackLocal --app --app-version 2.0   
31268 ??         0:00.71 BrowserStackLocal --app --app-version 2.0   
@shawnlobo96
Copy link

Hey @dimkin-eu

In case you need to run both the desktop app as well as use Webdriver IO for an automate test, you can use the local identifier option in your WebdriverIO configuration.

This will allow both the local connections to be run simultaneously (Desktop app for local + local binary for WebdriverIO)

You need to add the below

bs_local_args = { 'key': '<browserstack-accesskey>', 'localIdentifier': 'randomstring' }

Refer: https://github.com/browserstack/browserstack-local-nodejs#local-identifier

In your capabilities, within bstack:options, you need to add the same identifier using you defined in bs_local_args.

Your bstack:options block should look like:

"bstack:options": {
                "os": "Windows",
                "osVersion": "10",
                "resolution": "1920x1080",
                "networkLogs": "true",
                "video": "false",
                "localIdentifier": "randomstring",
                "seleniumVersion": "3.141.59"
            }

This will prevent the error from showing up

@dimkin-eu
Copy link
Author

@shawnlobo96 a little bit cumbersome, and looks like another workaround :)
And which id BrowserStackLocal uses? to not set the same ( you know, human random is pseudorandom :) )

@shawnlobo96
Copy link

@dimkin-eu this is indeed another workaround. Browserstack local does not set a local identifier by default. Ideally, when you require multiple binaries to be run with the same access_key, you would use a local identifier as this allows for multiple binaries to be spawned with the same credentials. This identifier can be any random characters or numbers.

Also, the local identifier you use is specific to your account.

Let's say you are using local identifier abc with your access_key, that would not affect my execution even if I specify the local identifier as abc since our accounts are different.

TLDR: you need to have the same localIdentifier in your capabilities as that used to start up the binary. You can think of it as a kind of mapping that maps the running test session with the binary instance.

You can write at '[email protected]' in case you still have any further questions or feedback :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants