Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@wdio/browserstack-service
Advanced tools
@wdio/browserstack-service is a WebdriverIO service that provides integration with BrowserStack, a cloud-based cross-browser testing platform. This service allows you to run your WebdriverIO tests on BrowserStack's infrastructure, enabling you to test your web applications across a wide range of browsers and devices.
BrowserStack Local Testing
This feature allows you to test your local applications on BrowserStack by establishing a secure connection between your local machine and BrowserStack's infrastructure.
const { remote } = require('webdriverio');
const browserstack = require('@wdio/browserstack-service');
const options = {
user: 'YOUR_BROWSERSTACK_USERNAME',
key: 'YOUR_BROWSERSTACK_ACCESS_KEY',
services: ['browserstack'],
capabilities: {
'bstack:options': {
os: 'Windows',
osVersion: '10',
local: true,
seleniumVersion: '3.141.59'
},
browserName: 'chrome',
browserVersion: 'latest'
}
};
(async () => {
const browser = await remote(options);
await browser.url('http://localhost:3000');
console.log(await browser.getTitle());
await browser.deleteSession();
})();
Parallel Testing
This feature allows you to run tests in parallel across multiple browsers and operating systems, significantly reducing the time required for test execution.
const { remote } = require('webdriverio');
const browserstack = require('@wdio/browserstack-service');
const options = {
user: 'YOUR_BROWSERSTACK_USERNAME',
key: 'YOUR_BROWSERSTACK_ACCESS_KEY',
services: ['browserstack'],
capabilities: [
{
'bstack:options': {
os: 'Windows',
osVersion: '10',
seleniumVersion: '3.141.59'
},
browserName: 'chrome',
browserVersion: 'latest'
},
{
'bstack:options': {
os: 'OS X',
osVersion: 'Big Sur',
seleniumVersion: '3.141.59'
},
browserName: 'safari',
browserVersion: 'latest'
}
]
};
(async () => {
const browser1 = await remote(options.capabilities[0]);
const browser2 = await remote(options.capabilities[1]);
await browser1.url('https://www.example.com');
await browser2.url('https://www.example.com');
console.log(await browser1.getTitle());
console.log(await browser2.getTitle());
await browser1.deleteSession();
await browser2.deleteSession();
})();
Automated Screenshots
This feature allows you to take automated screenshots of your web application during test execution, which can be useful for visual regression testing and debugging.
const { remote } = require('webdriverio');
const browserstack = require('@wdio/browserstack-service');
const options = {
user: 'YOUR_BROWSERSTACK_USERNAME',
key: 'YOUR_BROWSERSTACK_ACCESS_KEY',
services: ['browserstack'],
capabilities: {
'bstack:options': {
os: 'Windows',
osVersion: '10',
seleniumVersion: '3.141.59'
},
browserName: 'chrome',
browserVersion: 'latest'
}
};
(async () => {
const browser = await remote(options);
await browser.url('https://www.example.com');
await browser.saveScreenshot('./screenshot.png');
await browser.deleteSession();
})();
@wdio/sauce-service is a WebdriverIO service that provides integration with Sauce Labs, another cloud-based cross-browser testing platform. Similar to @wdio/browserstack-service, it allows you to run your WebdriverIO tests on Sauce Labs' infrastructure, offering features like parallel testing and automated screenshots.
WebdriverIO is a popular testing framework for Node.js that allows you to run tests on various browsers and devices. While it does not provide direct integration with BrowserStack or Sauce Labs, it can be extended with services like @wdio/browserstack-service and @wdio/sauce-service to achieve similar functionalities.
Nightwatch is an end-to-end testing framework that supports running tests on various browsers and devices. It offers built-in support for BrowserStack and Sauce Labs, making it a viable alternative to using WebdriverIO with @wdio/browserstack-service.
A WebdriverIO service that manages local tunnel and job metadata for BrowserStack users.
The easiest way is to keep @wdio/browserstack-service
as a devDependency in your package.json
, via:
npm install @wdio/browserstack-service --save-dev
Instructions on how to install WebdriverIO
can be found here.
WebdriverIO has BrowserStack support out of the box. You should set user
and key
in your wdio.conf.js
file. This service plugin provides support for BrowserStack Tunnel](https://www.browserstack.com/automate/node#setting-local-tunnel). Set browserstackLocal: true
also to activate this feature.
Reporting of session status on BrowserStack will respect strict
setting of Cucumber options.
// wdio.conf.js
exports.config
// ...
user: process.env.BROWSERSTACK_USERNAME,
key: process.env.BROWSERSTACK_ACCESS_KEY,
services: [
['browserstack', {
testObservability: true,
testObservabilityOptions: {
projectName: "Your project name goes here",
buildName: "The static build job name goes here e.g. Nightly regression"
},
browserstackLocal: true
}]
],
// ...
};
In order to authorize to the BrowserStack service your config needs to contain a user
and key
option.
By default, testObservability
is also enabled when you use the browserstack-service. You can read more about the advanced reporting and analytics functionalities of Test Observability
and also read about how it works
. You can visit the Test Observability dashboard after running your tests and also choose to disable it by setting the key to false
.
You can use Test Observability even if you do not want to run your tests on the BrowserStack infrastructure. You could be running your tests on CI or on your laptop or even on other cloud service providers like Sauce Labs, Test Observability could still work and give you all the intelligent test reports and advanced analytics.
You can set your config in the following manner if you do not want to run tests on BrowserStack Automate or App Automate (infrastructure) but still want to use Test Observability (note that user
and key
are now defined under the scope of the browserstack
service):
// wdio.conf.js
export const config = {
// ...
services: [
['browserstack', {
testObservability: true,
testObservabilityOptions: {
user: process.env.BROWSERSTACK_USERNAME,
key: process.env.BROWSERSTACK_ACCESS_KEY,
projectName: "Your project name goes here",
buildName: "The static build job name goes here e.g. Nightly regression"
}
}]
],
// ...
};
Read more
in BrowserStack documentation about how to get started with Test Observability.
Set this to true to enable routing connections from BrowserStack cloud through your computer.
Type: Boolean
Default: false
Set this to true to kill the BrowserStack Local process on complete, without waiting for the BrowserStack Local stop callback to be called. This is experimental and should not be used by all. Mostly necessary as a workaraound for this issue.
Type: Boolean
Default: false
Appium set this with app file path available locally on your machine to use the app as application under test for Appium sessions.
Type: String
or JsonObject
Default: undefined
List of available app values:
Use local available app file path as application under test for appium.
services: [
['browserstack', {
app: '/path/to/local/app.apk'
// OR
app: {
path: '/path/to/local/app.apk'
}
}]
]
Pass custom_id while app upload.
services: [
['browserstack', {
app: {
path: '/path/to/local/app.apk',
custom_id: 'custom_id'
}
}]
]
Use app url returned after uploading app to BrowserStack.
services: [
['browserstack', {
app: 'bs://<app-id>'
// OR
app: {
id: 'bs://<app-id>'
}
}]
]
use custom_id of already uploaded apps
services: [
['browserstack', {
app: 'custom_id'
// OR
app: {
custom_id: 'custom_id'
}
}]
]
use shareable_id of already uploaded apps
services: [
['browserstack', {
app: 'username/custom_id'
// OR
app: {
shareable_id: 'username/custom_id'
}
}]
]
Cucumber only. Set the BrowserStack Automate session name to the Scenario name if only a single Scenario ran. Useful when running in parallel with wdio-cucumber-parallel-execution.
Type: Boolean
Default: false
Customize the BrowserStack Automate session name format.
Type: Function
Default (Cucumber/Jasmine): (config, capabilities, suiteTitle) => suiteTitle
Default (Mocha): (config, capabilities, suiteTitle, testTitle) => suiteTitle + ' - ' + testTitle
Mocha only. Do not append the test title to the BrowserStack Automate session name.
Type: Boolean
Default: false
Mocha only. Prepend the top level suite title to the BrowserStack Automate session name.
Type: Boolean
Default: false
Automatically set the BrowserStack Automate session name.
Type: Boolean
Default: true
Automatically set the BrowserStack Automate session status (passed/failed).
Type: Boolean
Default: true
buildIdentifier is a unique id to differentiate every execution that gets appended to buildName. Choose your buildIdentifier format from the available expressions:
${BUILD_NUMBER}
: Generates an incremental counter with every execution${DATE_TIME}
: Generates a Timestamp with every execution. Eg. 05-Nov-19:30services: [
['browserstack', {
buildIdentifier: '#${BUILD_NUMBER}'
}]
]
Build Identifier supports usage of either or both expressions along with any other characters enabling custom formatting options.
BrowserStack Local options.
Type: Object
Default: {}
List of available local testing modifiers to be passed as opts:
If doing simultaneous multiple local testing connections, set this uniquely for different processes -
opts = { localIdentifier: "randomstring" };
To enable verbose logging -
opts = { verbose: "true" };
Note - Possible values for 'verbose' modifier are '1', '2', '3' and 'true'
To route all traffic via local(your) machine -
opts = { forceLocal: "true" };
To test local folder rather internal server, provide path to folder as value of this option -
opts = { f: "/my/awesome/folder" };
To kill other running BrowserStack Local instances -
opts = { force: "true" };
To disable local testing for Live and Screenshots, and enable only Automate -
opts = { onlyAutomate: "true" };
To use a proxy for local testing -
opts = {
proxyHost: "127.0.0.1",
proxyPort: "8000",
proxyUser: "user",
proxyPass: "password",
};
To use local proxy in local testing -
opts = {
localProxyHost: "127.0.0.1",
localProxyPort: "8000",
localProxyUser: "user",
localProxyPass: "password",
};
To use PAC (Proxy Auto-Configuration) in local testing -
opts = { "pac-file": "<pac_file_abs_path>" };
By default, BrowserStack local wrappers try downloading and executing the latest version of BrowserStack binary in ~/.browserstack or the present working directory or the tmp folder by order. But you can override these by passing the -binarypath argument. Path to specify local Binary path -
opts = { binarypath: "/path/to/binary" };
To save the logs to the file while running with the '-v' argument, you can specify the path of the file. By default the logs are saved in the local.log file in the present woring directory. To specify the path to file where the logs will be saved -
opts = { verbose: "true", logFile: "./local.log" };
For more information on WebdriverIO see the homepage.
FAQs
WebdriverIO service for better Browserstack integration
The npm package @wdio/browserstack-service receives a total of 88,705 weekly downloads. As such, @wdio/browserstack-service popularity was classified as popular.
We found that @wdio/browserstack-service demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.