Trying to run protractor tests in parallel - angularjs

I'm trying to run a bunch of tests in parallel using protractor.. it seems that I am using all the configs as I should but something isn't right and the tests are running one after the other in the same browser instance.
my .conf file is as follows:
// Some protractor configs
capabilities: {
browserName: 'chrome',
shardTestFiles: true,
maxInstance: 2,
},
suites: {
sitePersonalizationSanity: '../test/e2e/Sanity/*.js',
},
// Other protractor configs
I'll be glad to hear if I'm doing anything wrong.. thanks.

Your original problem was only with the spelling.
Use:
maxInstances: 2,
Instead of:
maxInstance: 2,

This could be your work around and works fro me.
you can specify the threads
in multicapabilities just mention like this
multiCapabilities: [
{
shardTestFiles: true,
maxInstances: 1,
sequential: true,
browserName: 'chrome',
specs: ['specs/spec1.js','specs/spec2.js','specs/spec3.js']
},
{
shardTestFiles: true,
maxInstances: 1,
sequential: true,
browserName: 'chrome',
specs: ['specs/spec4.js',
'specs/spec5.js',
'specs/spec6.js',
]
}
If you want you can include the maxSessions: 1, count: 1 too .
so that you can restrict the sessions
you can group the similar processing test cases together.
Hope this helps.
Kindly up-vote or select as correct answer if it works good.

Related

Using headless chrome displays empty part of the page

When using chromedriver in a protractor script, to test an angular page, I obtain different results using "Headless" or "Normal" browser.
Actually, if I use a "repeater" locator, to display the items in the "empty" list, it returns that there are 5 items, but the "headless" chrome driver fails to render them. Look at the screenshots.
I'm using ChromeDriver 2.45, which supports Chrome Version 70 to 72, I have version 71.
My OS is Windows 10.
Protractor version 5.1.1
Angularjs version 1.5
Here's the configuration file:
exports.config = {
directConnect: true,
rootElement: 'html',
chromeDriver: 'C:\\srv\\build\\applications\\chromedriver\\chromedriver_win32\\chromedriver.exe',
getPageTimeout: 60000,
allScriptsTimeout: 60000,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
'browserName': 'chrome',
chromeOptions:{
args:["--headless"]
}
},
specs: [ 'features/*.feature' ],
baseUrl: '',
cucumberOpts: {
tags: '',
require: [ 'steps/*.spec.js' ],
monochrome: true,
strict: true,
plugin: "json"
},
};
Seems to problem is in the window size. By default, headless mode is not a fullscreen, so some elements are automatically moved and hidden (as when you try manually to resize the window)
Just add to your conf:
driver.manage().window().maximize();
Can you update args to
capabilities: {
...,
chromeOptions: {
args: ["--headless", "--disable-gpu", "--window-size=800x600"]
}
}
For the exact configuration mentioned i am able to automate headless with no issues.
Reference https://github.com/angular/protractor/blob/master/docs/browser-setup.md#using-headless-chrome

Running both Chrome and IE 11 Protractor tests

Running Protractor E2E tests against both Chrome and IE is difficult.
I can run them separately, however I need to start/stop the respective Chrome/IE webdriver server before running each tests.
In my conf.js file, I export the config options like this :
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: [
'spec/my-spec.js',
],
directConnect: false, // false when targeting IE, and selen addr is used
multiCapabilities: [
{
browserName: 'chrome'
}
,
{
browserName: 'internet explorer',
'version': '11'
}
]
}
For the standard Chrome tests, I can kick off the Webdriver server:
> webdriver-manager start
But for IE, I discovered a way to run Webdriver IE as follows (yeah, pretty ugly):
java -Dwebdriver.ie.driver=C:\Projects\GSDashboard-E2ETests\node_modules\protractor\node_modules\webdriver-manager\selenium\IEDriverServer_x64_2.53.1.exe -jar C:\Projects\GSDashboard-E2ETests\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-2.53.1.jar
Then I just launch the Protractor tests:
protractor protractor.conf.js
I'm searching around for a cleaner and smoother way of running both IE/Chrome e2e tests in one shot.
Is there a solution to this ?
Any advice/guidance is appreciated....
****** UPDATE ******
As per answer below, trying to use seleniumArgs as follows (where I can specify the jar file OR the IEDriverServer_x64_2.53.1.exe file :
exports.config = {
//seleniumAddress: 'http://localhost:4444/wd/hub', // comment out
seleniumArgs: ['-Dwebdriver.ie.driver=C:\Projects\Dashb-E2ETests\node_modules\protractor\node_modules\webdriver-manager\selenium\IEDriverServer_x64_2.53.1.exe'],
allScriptsTimeout: 50000,
specs: [
'spec/MY-spec.js',
],
directConnect: false, // false when targeting IE, and selen addr is used
multiCapabilities: [
//{
// browserName: 'chrome',
,
{
browserName: 'internet explorer',
'version': '11'
}
]
}
BUT running the test throws this error in a windows cmd prompt:
E/launcher - The path to the driver executable must be set by the web driver.ie.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/InternetExplorer‌​Driver.
So, I still haven't figured out how to run both IE and Chrome tests (sequentially).
regards,
Bob
I had a similar problem and the solution was running this:
webdriver-manager update --ie
After that, both IE11 and Chrome instances run simultaneously with:
multiCapabilities: [
{
browserName: 'chrome'
}
,
{
browserName: 'internet explorer',
'version': '11'
}
]
include seleniumArgs: ['-Dwebdriver.ie.driver=pathtoIEdriver/IEDriverServer.exe'] property in the conf.js and remove seleniumAddress: 'http://localhost:4444/wd/hub'.If no seleniumAddress is mentioned ,then protractor will automatically start selenium server. So following will be your conf.js for running your protractor test against chrome and ie.
exports.config = {
seleniumArgs: ['-Dwebdriver.ie.driver=node_modules/protractor/selenium/IEDriverServer.exe'],
specs: [
'spec/my-spec.js',
],
directConnect: false, // false when targeting IE, and selen addr is used
multiCapabilities: [
{
browserName: 'chrome'
}
,
{
browserName: 'internet explorer',
'version': '11'
}
]
}

How to loop in Protractor config file?

I am new to JS and Protractor for testing functionalities. I need to include some conditions or loops inside 'Configuration' file of protractor.
Such as, if I need to check my specs running on 'Windows / Mac' platform and a variable provides these details.
I am expecting something like :
exports.config = {
seleniumAddress : 'http://localhost:4444/wd/hub',
getPageTimeout : 30000,
allScriptsTimeout : 30000,
specs : [ ],
framework : 'jasmine2',
***don't know the syntax, am expecting below line and condition need to work for protractor***
***var platform = 'Windows',
if(platform ==='Windows'){***
multiCapabilities: [{
'browserName': 'chrome',
'specs': ['spec1.js']
},
***else {***
'browserName': 'chrome',
'specs': ['spec2.js']
}],
};
Is it possible to validate in Configuration file?
You need to use the getMultiCapabilities function:
getMultiCapabilities: function() {
// TODO: check platform and return list of capability objects
},

Protractor multiCapabilities doesn't support suite config?

I'm just starting to add parallel testing to my config file and I'm running into an issue that I'm having trouble discerning elsewhere if its possible or not from Protractor. My multiCapabilities set up looks like this at the moment:
multiCapabilities:[{
browserName: 'chrome',
name: 'chrome-tests',
count: 1,
shardTestFiles: true,
maxInstances: 1,
suites: {
repeatable: 'example/example.spec.js'
}
}, {
browserName: 'firefox',
name: 'ff-tests',
count: 1,
shardTestFiles: true,
maxInstances: 1,
suites: {
repeatable: 'example/example.spec.js'
}
}],
and it fails with an error message of:
Cannot read property 'repeatable' of undefined
Am I missing something or does multiCapability not support suites running in parallel?
suites can only be defined on the upper level in your config. They cannot be capability-specific.

Protractor e2e testing Maximum limit for Multiuser testing

I am writing e2e test cases for my Angular application using protractor.I am trying to generate HTML Reports and multiuser testing. This is my
conf.js :
var HtmlReporter = require('protractor-html-screenshot-reporter');
var reporter=new HtmlReporter({
baseDirectory: '/test/e2e/JasmineReporter', // a location to store screen shots.
docTitle: 'Report',
docName: 'protractor-demo-tests-report.html'
});
exports.config = {
seleniumAddress: 'http://localhost:4441/wd/hub',
multiCapabilities: [{
browserName: 'chrome',
acceptSslCerts: true,
trustAllSSLCertificates: true,
specs: ['first_spec.js']
}, {
browserName: 'chrome',
acceptSslCerts: true,
trustAllSSLCertificates: true,
specs: ['second_spec.js']
}],
maxSessions: 1, //Limits max number of instances
onPrepare: function() {
jasmine.getEnv().addReporter(reporter);
},
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 50000
}
};
Now, it is working fine. It is generating HTML Reports for two specs.
But when I limit the instances using maxSessions: 1 (It opens one browser at a time). It is generating report for last spec. And what is the max number of instances we can run.

Resources