Get your setup working faster. Join our Discord for optimisation tips from elite testers.
Join our Discord
Multiple Local Testing Connections
You can test multiple forks and builds at the same time by setting up separate Local Testing connections for each.
To do this, use one of the following options:
If you are using the BrowserStack SDK, add the following snippet to your browserstack.yml file:
```yml
browserStackLocalOptions:
localIdentifier: randomstring
```
Copy icon
Copy
```js
// wdio.conf.js
export const config = {
// ... (user, key, hostname)
services: [
[
'browserstack',
{
browserstackLocal: true,
browserstackLocalOptions: {
// Labeling the tunnel binary
localIdentifier: "randomstring",
forcelocal: true
},
testObservability: true,
},
],
],
commonCapabilities: {
"bstack:options": {
local: true,
// Telling the remote browser exactly which tunnel to join
localIdentifier: "randomstring",
debug: true
}
},
capabilities: [
{
browserName: 'Chrome',
'bstack:options': {
os: 'Windows',
osVersion: '11'
}
}
]
};
exports.config.capabilities.forEach(function (caps) {
for (let i in exports.config.commonCapabilities)
caps[i] = { ...caps[i], ...exports.config.commonCapabilities[i]};
});
// nightwatch.conf.js
module.exports = {
// ... (plugins)
'@nightwatch/browserstack': {
browserstackLocal: true,
browserstackLocalOptions: {
// Named tunnel for the binary
localIdentifier: 'randomstring',
forcelocal: 'true'
},
test_observability: {
enabled: true
}
},
test_settings: {
'browserstack.local_identified': {
// ... (webdriver/selenium host settings)
desiredCapabilities: {
browserName: 'Chrome',
'bstack:options': {
os: 'Windows',
osVersion: '11',
local: true,
// Mapping the session to the named tunnel
localIdentifier: 'randomstring'
}
}
}
}
};
```
Copy icon
Copy
Add the following snippet to your test scripts:
bsLocalArgs . put ( "localIdentifier" , "randomstring" );
bs_local_args = { ' key ' : ' <browserstack-accesskey> ' , ' localIdentifier ' : ' randomstring ' }
bsLocalArgs . Add ( new KeyValuePair < string , string >( "localIdentifier" , "randomstring" ));
my % bs_local_args = ( "key" => "<browserstack-accesskey>" , "localIdentifier" => "randomstring" );
bs_local_args = { "key" : "<browserstack-accesskey>" , "localIdentifier" : "randomstring" }
bs_local_args = { "key" => "<browserstack-accesskey>" , "localIdentifier" => "randomstring" }
my %bs_local_args = (" key " => " <browserstack-accesskey> ", " localIdentifier " => " randomstring ");
Establish each Local Testing connection using the --local-identifier flag, along with a unique connection name (for instance, Test 123 ).
Note: Not using the --local-identifier flag (for each Local Testing connection) will cut off the existing connection and create a new one.
Run the binary using the following command:
./BrowserStackLocal --key YOUR_ACCESS_KEY --local-identifier Test123
BrowserStackLocal.exe --key YOUR_ACCESS_KEY --local-identifier Test123
After establishing Local Testing connections, configure the test script to run through a specific connection. To do so, set the browserstack.localIdentifier capability in your test scripts and add the unique connection name as parameter.
caps . setCapability ( "browserstack.local" , "true" );
caps . setCapability ( "browserstack.localIdentifier" , "Test123" );
var capabilities = {
' browserstack.local ' : ' true ' ,
' browserstack.localIdentifier ' : ' Test123 '
}
caps . SetCapability ( "browserstack.local" , "true" );
caps . SetCapability ( "browserstack.localIdentifier" , "Test123" )
$caps [ 'browserstack.local' ] = "true" ;
$caps [ 'browserstack.localIdentifier' ] = "Test123" ;
caps [ 'browserstack.local' ] = True
caps [ 'browserstack.localIdentifier' ] = 'Test123'
caps [ 'browserstack.local' ] = 'true'
caps [ 'browserstack.localIdentifier' ] = 'Test123'
my $caps = {
" browserstack.local " => " true ",
" browserstack.localIdentifier " => " Test123 "
};
Managing multiple Local Testing connections
You can use the Local Testing API to check the status of (or disconnect) active binaries. However, your connections will not show up in the API response unless you establish them using --enable-logging-for-api flag, as follows:
./BrowserStackLocal --key YOUR_ACCESS_KEY --enable-logging-for-api <other_params>
Is this page helping you?
Thank you for your valuable feedback!