Browserstack multiple browser does not run for protractor - cross-browser

I am trying to run multiple browsers in parallel using browser stack but it does not seem possible with it. This is is my config file
exports.config = {
capabilities: {
'browserstack.user' : 'abc2',
'browserstack.key' : 'asdasdasdasdj',
// Needed for testing localhost
'browserstack.local' : 'false',
multiCapabilities: [
{
browserName: 'Safari',
browser_version: '8.0',
os: 'OS X',
os_version: 'Yosemite'
},
{
browserName: 'Firefox',
browser_version: '30.0',
os: 'Windows',
os_version: '7'
},
{
browserName: 'iPhone',
platform: 'MAC',
device: 'iPhone 5S'
}
]
},
When i run - npm run protractor, i get this error Target browser must be a string, but is ; did you forget to call forBrowser()?

You need to specify browserName capability under capabilities block. Below is a working sample
exports.config = {
'specs': [ '../specs/single.js' ],
'seleniumAddress': 'http://hub-cloud.browserstack.com/wd/hub',
'commonCapabilities': {
'browserstack.user': process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME',
'browserstack.key': process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY',
'build': 'protractor-browserstack',
'name': 'parallel_test',
'browserstack.debug': 'true',
'browserName': 'Chrome'
},
'multiCapabilities': [{
'browserName': 'Chrome'
},{
'browserName': 'Safari'
},{
'browserName': 'Firefox'
},{
'browserName': 'IE'
}]
};
// Code to support common capabilities
exports.config.multiCapabilities.forEach(function(caps){
for(var i in exports.config.commonCapabilities) caps[i] = caps[i] || exports.config.commonCapabilities[i];
});
The 'browserName': 'Chrome' capability will later be overriden by your multiCapabilities block.

Related

Protractor capabilities.proxy equivalent in puppeteer

I am trying to use puppeteer instead of protractor.
In protractor config, I can use this config for proxy:
capabilities: {
browserName: 'chrome',
chromeOptions: {
binary: chromeBin,
args: [
'--window-size=1920,1080',
'--proxy-server=http://my-proxy/',
'--proxy-bypass-list=http://localhost'
]
},
proxy: {
proxyType: 'manual',
httpProxy: 'http://my-proxy'
}
}
It seems like what's inside chromeOptions matches the settings in puppeteer.launch:
browser = await puppeteer.launch({
executablePath: chromeBin,
headless,
args: [
'--window-size=1920,1080',
'--proxy-server=http://my-proxy',
'--proxy-bypass-list=http://localhost'
]
});
But where do I put the proxy in capabilities? I am not able to launch the page because of proxy issues.

protractor-html-screenshot-reporter does not work

I have done everything as written on https://www.npmjs.com/package/protractor-html-screenshot-reporter, but no HTML or screenshots are saved to folder.
I've installed protractor-html-screenshot-reporter with command:
npm install protractor-html-screenshot-reporter --save-dev
I have then done npm init and saved package.json file, which contains:
...
"devDependencies": {
"jasmine-reporters": "^2.2.0",
"protractor-html-screenshot-reporter": "0.0.21"
},
...
I can also see protractor-html-screenshot-reporter in /node_modules/ folder.
In config file I have the following:
var HtmlReporter = require('protractor-html-screenshot-reporter');
exports.config = {
...
jasmineNodeOpts: {
showColors: true, // Use colors in the command line report.
onComplete: null,
isVerbose: false,
includeStackTrace: false,
defaultTimeoutInterval: 1000000,
print: function() {}
},
onPrepare: function() {
jasmine.getEnv().addReporter(new HtmlReporter({
baseDirectory: '../reports/screenshots',
takeScreenShotsOnlyForFailedSpecs: true,
docTitle: 'Desk test report',
docName: 'desk_report.html',
preserveDirectory: true
}));
}
}
Now when I run protractor conf.js I don't see any /reports/screenshots folder, HTML report or screenshot created. Help please!
Jasmine allure Reporter is better for reports and screenshots
Below is the code for it:
//conf.js
exports.config = {
framework: 'jasmine2',
jasmineNodeOpts: {
showColors: true,
includeStackTrace: true,
defaultTimeoutInterval: 144000000
},
directConnect: true,
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['/**/Tests/**/*test.js'],
capabilities: { 'browserName': 'chrome' },
onPrepare: function () {
browser.manage().timeouts().implicitlyWait(15000);
var AllureReporter = require('jasmine-allure-reporter');
jasmine.getEnv().addReporter(new AllureReporter({
allureReport: {
resultsDir: 'allure-results'
}
}));
jasmine.getEnv().afterEach(function (done) {
browser.takeScreenshot().then(function (png) {
allure.createAttachment('Screenshot', function () {
return new Buffer(png, 'base64');
}, 'image/png')();
done();
});
});
}
I Hope this solves your problem. Visit the Link for more information.

Protractor running some tests in parallel and some tests sequentially

I have a situation where I want to run some protractor tests in parallel in order to save time taken to run the tests. The difficulty I have is that some of these tests can't be run in parallel as the results in 1 browser are affecting the expected results in another session.
Is it possible to set my protractor config file in order to be able to do this? My current setup is shown below but this isn't working:
multiCapabilities: [
//tests run sequentially
{'browserName': 'firefox', specs: ['e2e/DynamicUpdates/**/*.spec.js'], maxInstances: 1, exclude: ['e2e/main/**/*.spec.js']},
{'browserName': 'chrome', specs: ['e2e/DynamicUpdates/**/*.spec.js'], maxInstances: 1, exclude: ['e2e/main/**/*.spec.js']},
{'browserName': 'internet explorer', specs: ['e2e/DynamicUpdates/**/*.spec.js'], maxInstances: 1, exclude: ['e2e/main/**/*.spec.js']},
{'browserName': 'safari', specs: ['e2e/DynamicUpdates/**/*.spec.js'], maxInstances: 1, exclude: ['e2e/main/**/*.spec.js']},
// Main tests - run in parallel
{'browserName': 'chrome', 'chromeOptions': {args: ['--start-maximized']}, shardTestFiles: true, maxInstances: 3},
{'browserName': 'firefox', shardTestFiles: true, maxInstances: 3},
{'browserName': 'safari', shardTestFiles: true, maxInstances: 3},
{
'browserName': 'internet explorer',
'binary': 'C:/Program Files (x86)/Internet Explorer/iexplore.exe',
'ensureCleanSession': true,
'nativeEvents': false,
'ignoreProtectedModeSettings': true,
'disable-popup-blocking': true,
'enablePersistentHover': true,
shardTestFiles: true,
maxInstances: 3
},
// Performance tests (currently not run against IE due to webdriver issues)
{'browserName': 'chrome', specs: ['/**/*.spec.js'] },
{'browserName': 'firefox', specs: ['/**/*.spec.js'] },
],
maxSessions: 3,
In the specs array, type out the files in order that you want them to run in. Or keep it the way it is and change the names of the files so they run in the proper sequence.
{'browserName': 'firefox',
specs: ['e2e/DynamicUpdates/folder1/testA.spec.js', 'e2e/DynamicUpdates/folder1/testB.spec.js', 'e2e/DynamicUpdates/folder1/testC.spec.js'],
maxInstances: 1, exclude: ['e2e/main/**/*.spec.js']},

Configure wallaby for React-redux-es6-typescript-immutable applications

How to configure wallaby for React-redux-es6-typescript-immutable application. I use webstorm editor. My base code is committed here
I tried the following code in wallaby.js, but it throws
ReferenceError: Can't find variable: exports
at src/store.ts:3
module.exports = function (wallaby) {
return {
files: [
'src/*.ts'
],
tests: [
'test/*Spec.ts'
],
compilers: {
'**/*.ts': wallaby.compilers.typeScript({
module: 5, // ES6
target: 2 // ES6
})
},
preprocessors: {
'**/*.js': file => require('babel-core').transform(
file.content,
{sourceMap: true, presets: ['es2015']})
}
}
}
I have more or less the same setup as you. Did you try setting the env variable to node?
My working wallaby.js config file for babel 6 is the following:
module.exports = function() {
return {
files: [
{pattern: "src/**/*.js*"}
],
tests: [
{pattern: "tests/integration/*.js"}
],
env: {
type: "node"
},
preprocessors: {
"**/*.js": file => require("babel-core").transform(file.content, {sourceMap: true, presets: ["es2015"]})
}
};
};

Timeouts testing polymer elements with web-component-tester and sauce labs

We're having trouble testing our polymer elements with web-component-tester and Sauce Labs. When we try to test with more browsers than our subscription level allows to run simultaneously, the tests that don't run immediately eventually time out. It seems really wrong that sauce labs and/or WCT doesn't know how to wait to begin executing a test until the other tests are finished, so that we can queue up as many tests as we wish without having to worry about VM utilization.
Has anyone figured this out? Thanks.
Here is our wct.conf.js in case it helps:
module.exports = {
testTimeout: 600 * 1000,
persistent: false,
ttyOutput: false,
verbose: false,
expanded: true,
browserOptions: {
name: "TWT Component Tests"
},
suites: [
'elements/twt-elements/test/index.html'
],
root: 'app',
webserver: {
pathMappings: [
{'/secrets.json': '../db/secrets.json'},
],
},
plugins: {
local: {
disabled: false,
browsers: ['chrome', 'safari', 'canary', 'firefox']
},
sauce: {
disabled: false,
commandTimeout: 600,
idleTimeout: 180,
browsers: [
/* see https://docs.saucelabs.com/reference/platforms-configurator */
/* support matrix: https://docs.google.com/spreadsheets/d/1XqTxODsi2s2GGllld1yHImtb-2ubCX1XbRsvZ4DqpZI */
{
browserName: "chrome",
platform: "OS X 10.9",
version: "40"
},
{
browserName: "safari",
platform: "OS X 10.9",
version: "7.0"
},
{
browserName: "safari",
platform: "OS X 10.10",
version: "8.0"
},
{
browserName: "chrome",
platform: "Windows 8.1",
version: "40"
},
{
browserName: "internet explorer",
platform: "Windows 8.1",
version: "11.0"
},
{
browserName: "firefox",
platform: "Windows 7",
version: "27.0"
},
{
browserName: "internet explorer",
platform: "Windows 7",
version: "10.0"
},
]
}
}
};