Online Training: Web test automation with CodeceptJS. Sign up now!

Running tests on BrowserStack on multiple browsers with Javascript

Hi guys. I am trying to run my tests on BrowserStack on multiple browsers. I am using webdriver helper and I kind of formed the config file.
However, Whenever I try to run my tests on more than one browser (which is supposed to be the purpose of running on multiple browsers though) the test on at least one of the browsers is always failing. If I run them one by one then there is no problem. The browser failing also is not consistent which is quite annoying. Have you encountered this kind of problem or do you have any solution? Here you can find my config file (which is slightly different than the documentation on Codecept because the configs on the the documentations are not working at all.):
`` exports.config = {
tests: ‘./*_test.js’,
output: ‘./output’,
helpers: {
WebDriver: {
url: ‘http://localhost:3333/’,
browser: ‘Chrome’,
name: ‘test of name’,
capabilities: {
‘project’: ‘projectname’,
‘build’: ‘buildname’,
‘name’: ‘name on basic capabilities’,
‘os’: ‘OS X’,
‘os_version’: ‘Mojave’,
‘browser_version’: ‘78.0’
}
}
},
plugins: {
wdio: {
enabled: true,
services: [‘browserstack’],
user: ‘blablabla’,
key: ‘blablabla’,
browserstackLocal: true
}
},
multiple: {
“basic”: {
browsers: [
{
browser: ‘Chrome’,
capabilities: {
‘os’: ‘OS X’,
‘os_version’: ‘Mojave’,
‘browser_version’: ‘77.0’,
“project”: ‘projectNamechromemulti’,
“build”: ‘buildNamechromemulti’,
‘name’: ‘name of Chrome’
}
},
{
browser: ‘Firefox’,
capabilities: {
“os”: ‘OS X’,
“os_version”: ‘Mojave’,
“browser_version”: ‘71.0’,
“project”: ‘projectNameFirefoxmulti’,
“build”: ‘buildNameFirefoxmulti’,
‘name’: ‘name of Firefox’
}
},
{
browser: ‘Safari’,
capabilities: {
‘os’: ‘OS X’,
‘os_version’: ‘Mojave’,
‘browser_version’: ‘12.1’,
“project”: ‘projectNameSafariMulti’,
“build”: ‘buildNameSafariMulti’,
‘name’: ‘name of Safari’
}
}
]
}
},
include: {
I: ‘./steps_file.js’
},
bootstrap: null,
mocha: {},
name: ‘nomad-browserStack-codeceptjs’
};

If I use this command "npx codeceptjs run-multiple basic --steps ", then I am having at least one failing test even before connecting to browserstack which is “LocalError: Error: Could not setup Local Testing.” and it is not certain which browser it fails, it always differs.
If I use this command “npx codeceptjs run-multiple basic:Safari --steps” or “npx codeceptjs run-multiple basic:Chrome --steps” or “npx codeceptjs run-multiple basic:Firefox --steps” then it runs without any problem and the test passes.

Sometimes I even get this error immediately I run the test for any browser: " Error: Can’t connect to WebDriver.
Error: Failed to create session.
[browserstack.local] is set to true but local testing through BrowserStack is not connected.

Please make sure Selenium Server (ChromeDriver or PhantomJS) is running and accessible"

So it expects selenium standalone to be started even though it is supposed to connect to browserstack, which is weird.

I think you have to enable the local testing option on Browser stack first.