grunt-protractor-runner
grunt-protractor-runner copied to clipboard
Added support for multiCapabilities object and splitTestsBetweenCapabilities boolean
These two parameters were fairly recently added to protractor and I'd like to be able to pass them directly into my protractor config file from the gruntfile.
@rrazey Have you tested multiCapabilities
argument? Do you have a sample working configuration?
Because I think protractor
reads multiCapabilities
from its config file as an array of objects and I still don't know how to pass an array of objects via command-line argument. Your patch pass it as an object not an array of objects.
ref: #42 and #25
I have tested this. Actually, as far as I could tell, protractor was not taking multiCapabilities from the command line at all, so I submitted a PR on the protractor project to rectify that: angular/protractor#860
The command gets sent to protrator with these arguments:
--multiCapabilities.0.browserName chrome --multiCapabilities.0.count 4 --multiCapabilities.1.browserName firefox --multiCapabilities.1.count 2
which is equivalent to this array:
multiCapabilities: [{
'browserName': 'chrome',
'count': 4
} , {
'browserName': 'firefox',
'count': 2
}
This is consistent with the params argument - to pass an array of objects to protractor via command line, this is the format:
--params.0 safe --params.1 qa
As soon as the protractor PR makes its way through, this should work. I'm fine with holding off on merging this one in until the protractor PR is merged in.
How would you call for instance of browsers now, if in example with one browser it was: browser.get('url');
How to open test in chrome, and in the middle of the test to open in firefox?
@lovacuzitu This isn't what the multiCapabilities object is used for. It's used to execute your tests in parallel, either on different browsers for browser specific testing, or on multiple instances of the same browser to speed up your test execution. I suggest reading more about it, here are some suggested start points:
https://github.com/angular/protractor/pull/492 https://github.com/angular/protractor/issues/605
Hi,
i've patched the two given files "protractor/lib/cli.js" and "grunt-protractor-runner/tasks/protractor_runner.js" but it does not work like expected.
if i setup multiple browsers in the following form:
multiCapabilities: [ {
'browserName': 'firefox',
'version': '25',
'platform': 'VISTA'
}, {
'browserName': 'firefox',
'version': '26',
'platform': 'LINUX'
}]
There will be an error from selenium "cannot find : Capabilities ..." so i think this is the same error as my prior ticket (#59).
Ill thik the problem is, that one or more of my paramters ("version") is not supportet by protractor as an parameter for the config file?
Can anyone confirm this and/or extend the protractor-config? (ill rarely speaking javascript so ill dont understand anything in the protractor code :D)
Hint: If ill define the multiCapabilities inside the protractor.conf.js the tests will run on all given Browsers in the correct version on the correct system. So ill (hopfully) know what im doing :D
@Brootux I pasted your snippet into my gruntfile and am having no issues running either locally or in Saucelabs. I suspect that it's not related to these updates.
Hm, okay. How was your exact setup in Gruntfile.js? What version of Selenium do you got? (ive got 2.41.0) Did you set up a version in the selenium config like this:
"capabilities":
[
{
"browserName": "firefox",
"version": "25",
"firefox_binary": "C:\\Program Files (x86)\\Mozilla Firefox 25\\firefox.exe",
"firefox_profile": "Firefox_25",
"platform": "WINDOWS",
"maxInstances": 1
},
{
"browserName": "firefox",
"version": "26",
"firefox_binary": "C:\\Program Files (x86)\\Mozilla Firefox 26\\firefox.exe",
"firefox_profile": "Firefox_26",
"platform": "WINDOWS",
"maxInstances": 1
},
...
?
You're right, ill think this has noting to do with this update :) (but ill said this in my prior comment)
Is there any status update on this? This would be great to land to allow for SauceLabs testing.
Hi there,
after testing a lot i have found my error. Ive had installed two versions of protractor, the "normal" and the one, that comes with the grunt-protractor-runner. So my npm-package view was like this:
|-> protractor
|-> grunt-protractor-runner
|-> protractor
So ive had always patched the "normal" protractor, but this had no effect on the behaviour of grunt-protractor-runner. After deleting the "normal" protractor package and patching your given protractor-patch (angular/protractor#860) to the right protractor installation the execution of multiple Browsers has worked.
But then i encountered my other problem with the setup of the version of the browser. After trying a lot ive found the problem.
After calling "flattenObject" there was the following structure for a capability:
{
browserName: 'firefox',
version: 30,
platform: 'MAC',
count: 1
}
As you can see, the version was "parsed" from flattenObject() as a number, not a string. So ive manipulated the flattenObject()-Method to "parse" the version as a string:
out[prefix + prop] = '' + obj[prop];
With that, the structure for a capability is
{
browserName: 'firefox',
version: '30',
platform: 'MAC',
count: 1
}
And now everything works fine.
You now get my 1up to merge this into the project :)
@rrazey After i saw, that the merging of your protractor-patch was closed ive created a new pull-request with your code and my extensions here: angular/protractor#1083
The last comment here lasts from 2 months, will this pull request be checked soon ? Or should I move on and merge manually the commit allowing for this ?
@hilnius Does this PR work? I thought it has been waiting for the PR angular/protractor#860 or angular/protractor#1083 to be merged to protractor??
Yeah, @hilnius please create some pressure to angular/protractor#1083 :)
Any updates on this feature?
I was going to create a pull request for this but found that rrazey already did it. Github has marked this PR as containing a merge conflict. Would teerapap mind merging this in? If you'd like, I can create another PR to take care of the merge conflict.
/bump :+1:
This would be a really useful (jenkins, saucelabs/local testing) if we could get it merged, is it possible for anyone else to correct the merge conflicts?
Hello this issue continues, I solve calling a different config file in the task watch I like run multiCapabilities. Wait a better solution....
I want this too, because I'd like to have my config in the gruntfile.
See PR https://github.com/teerapap/grunt-protractor-runner/pull/131
Thanks for working on this, t0mtaylor!
how can we add max duration to load a page completely?
Hi, I've tried using multiCapabilities with grunt-protractor-runner v5.0.0 but it is not yet supported. I just wanted to check what is the status of this feature?
Thanks, Nenad