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.
browserstack-capabilities
Advanced tools
An easier way to generate multiple capabilities based on JSON filters.
An easier way to generate multiple capabilities based on JSON filters for Browserstack.
npm install browserstack-capabilities
The create
method (currently the only method returned) accepts two parameters: an "include" and an "exclude" JSON filter.
The "include" filter will find all browsers that match the defined properties.
The "exclude" filter will return all browsers that don't match the defined properties.
You do not have to include all properties in your search. Any properties not defined will be included in all variations.
var username = "<browserstack username>";
var key = "<browserstack key>";
var bsCapabilities = require("browserstack-capabilities")(username, key);
var capabilities = bsCapabilities.create({
browser: "ie",
browser_version: "10.0"
});
console.log(capabilities);
// outputs:
// [{
// device: null,
// os: 'Windows',
// browser: 'ie',
// os_version: '8',
// browser_version: '10.0'
// }, {
// device: null,
// os: 'Windows',
// browser: 'ie',
// os_version: '7',
// browser_version: '10.0'
// }]
You can define multiple values per property:
var username = "<browserstack username>";
var key = "<browserstack key>";
var bsCapabilities = require("browserstack-capabilities")(username, key);
var capabilities = bsCapabilities.create({
browser: "ie",
browser_version: ["11.0", "10.0"],
os_version: ["10", "8.1", "7"]
});
console.log(capabilities);
// outputs:
// [{
// device: null,
// os: 'Windows',
// browser: 'ie',
// os_version: '10',
// browser_version: '11.0'
// }, {
// device: null,
// os: 'Windows',
// browser: 'ie',
// os_version: '8.1',
// browser_version: '11.0'
// }, {
// device: null,
// os: 'Windows',
// browser: 'ie',
// os_version: '7',
// browser_version: '11.0'
// }, {
// device: null,
// os: 'Windows',
// browser: 'ie',
// os_version: '7',
// browser_version: '10.0'
// }]
Includes and excludes can be combined to create complex scenarios. For example, I want all version of IE11 & IE10, except I don't care about IE11 on Windows 7:
var username = "<browserstack username>";
var key = "<browserstack key>";
var bsCapabilities = require("browserstack-capabilities")(username, key);
var capabilities = bsCapabilities.create({
browser: "ie",
browser_version: ["11.0", "10.0"],
os_version: ["10", "8.1", "7"]
}, {
browser_version: "11.0",
os_version: "7"
});
console.log(capabilities);
// outputs:
// [{
// device: null,
// os: 'Windows',
// browser: 'ie',
// os_version: '10',
// browser_version: '11.0'
// }, {
// device: null,
// os: 'Windows',
// browser: 'ie',
// os_version: '8.1',
// browser_version: '11.0'
// }, {
// device: null,
// os: 'Windows',
// browser: 'ie',
// os_version: '7',
// browser_version: '10.0'
// }]
The following properties are defined in the JSON browser data:
You can generate sample capabilities for single browsers on the Browserstack website.
Because each OS has a unique version and/or device name, you can create combinations for them by including the information together:
var username = "<browserstack username>";
var key = "<browserstack key>";
var bsCapabilities = require("browserstack-capabilities")(username, key);
var capabilities = bsCapabilities.create({
browser: "firefox",
os: ["Windows", "OS X"],
browser_version: "42.0",
os_version: ["10", "8.1", "El Capitan", "Yosemite"]
});
console.log(capabilities);
// outputs:
// [{
// device: null,
// os: 'Windows',
// browser: 'firefox',
// os_version: '10',
// browser_version: '42.0'
// }, {
// device: null,
// os: 'Windows',
// browser: 'firefox',
// os_version: '8.1',
// browser_version: '42.0'
// }, {
// device: null,
// os: 'OS X',
// browser: 'firefox',
// os_version: 'El Capitan',
// browser_version: '42.0'
// }, {
// device: null,
// os: 'OS X',
// browser: 'firefox',
// os_version: 'Yosemite',
// browser_version: '42.0'
// }]
You can create combinations for multiple browsers at the same time by passing an array of filters into the create function:
var username = "<browserstack username>";
var key = "<browserstack key>";
var bsCapabilities = require("browserstack-capabilities")(username, key);
var capabilities = bsCapabilities.create([{
browser: "firefox",
browser_version: "42.0",
os: "Windows",
os_version: ["10", "8.1"]
},{
browser: "chrome",
browser_version: "46.0",
os: "Windows",
os_version: ["10", "8.1"]
}]);
console.log(capabilities);
// outputs:
// [{
// device: null,
// os: 'Windows',
// browser: 'firefox',
// os_version: '10',
// browser_version: '42.0'
// }, {
// device: null,
// os: 'Windows',
// browser: 'firefox',
// os_version: '8.1',
// browser_version: '42.0'
// }, {
// device: null,
// os: 'Windows',
// browser: 'chrome',
// os_version: '10',
// browser_version: '46.0'
// }, {
// device: null,
// os: 'Windows',
// browser: 'chrome',
// os_version: '8.1',
// browser_version: '46.0'
// }]
If you prefer, you can create combinations for different browsers separately. Once created, you can concat the combinations:
var username = "<browserstack username>";
var key = "<browserstack key>";
var bsCapabilities = require("browserstack-capabilities")(username, key);
var ff = bsCapabilities.create({
browser: "firefox",
os: "Windows",
browser_version: "42.0",
os_version: ["10", "8.1"]
});
var chrome = bsCapabilities.create({
browser: "chrome",
os: "Windows",
browser_version: "46.0",
os_version: ["10", "8.1"]
});
var capabilities = ff.concat(chrome);
console.log(capabilities);
// outputs:
// [{
// device: null,
// os: 'Windows',
// browser: 'firefox',
// os_version: '10',
// browser_version: '42.0'
// }, {
// device: null,
// os: 'Windows',
// browser: 'firefox',
// os_version: '8.1',
// browser_version: '42.0'
// }, {
// device: null,
// os: 'Windows',
// browser: 'chrome',
// os_version: '10',
// browser_version: '46.0'
// }, {
// device: null,
// os: 'Windows',
// browser: 'chrome',
// os_version: '8.1',
// browser_version: '46.0'
// }]
You can select the current (exclude betas), latest (include betas) or previous version of a browser for an OS by passing in the string "current", "latest" or "previous" as the browser version:
var username = "<browserstack username>";
var key = "<browserstack key>";
var bsCapabilities = require("browserstack-capabilities")(username, key);
var capabilities = bsCapabilities.create({
browser: "ie",
browser_version: ["current"],
os: "Windows",
os_version: ["XP", "7", "8", "8.1", "10"]
});
console.log(capabilities);
// outputs:
// [{
// os: 'Windows',
// os_version: 'XP',
// browser: 'ie',
// device: null,
// browser_version: '8.0'
// }, {
// os: 'Windows',
// os_version: '7',
// browser: 'ie',
// device: null,
// browser_version: '11.0'
// }, {
// os: 'Windows',
// os_version: '8',
// browser: 'ie',
// device: null,
// browser_version: '10.0'
// }, {
// os: 'Windows',
// os_version: '8.1',
// browser: 'ie',
// device: null,
// browser_version: '11.0'
// }, {
// os: 'Windows',
// os_version: '10',
// browser: 'ie',
// device: null,
// browser_version: '11.0'
// }]
FAQs
An easier way to generate multiple capabilities based on JSON filters.
The npm package browserstack-capabilities receives a total of 155 weekly downloads. As such, browserstack-capabilities popularity was classified as not popular.
We found that browserstack-capabilities demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.