grunt-protractor-runner icon indicating copy to clipboard operation
grunt-protractor-runner copied to clipboard

Added support for multiCapabilities object and splitTestsBetweenCapabilities boolean

Open rrazey opened this issue 10 years ago • 23 comments

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 avatar May 23 '14 21:05 rrazey

@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

teerapap avatar May 24 '14 14:05 teerapap

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.

rrazey avatar May 24 '14 21:05 rrazey

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 avatar May 26 '14 08:05 lovacuzitu

@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

rrazey avatar May 27 '14 16:05 rrazey

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 avatar May 28 '14 14:05 Brootux

@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.

rrazey avatar May 28 '14 16:05 rrazey

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)

Brootux avatar Jun 02 '14 05:06 Brootux

Is there any status update on this? This would be great to land to allow for SauceLabs testing.

nowells avatar Jun 20 '14 15:06 nowells

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 :)

Brootux avatar Jul 17 '14 10:07 Brootux

@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

Brootux avatar Jul 17 '14 10:07 Brootux

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 avatar Sep 15 '14 14:09 hilnius

@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??

teerapap avatar Sep 15 '14 16:09 teerapap

Yeah, @hilnius please create some pressure to angular/protractor#1083 :)

Brootux avatar Sep 17 '14 11:09 Brootux

Any updates on this feature?

AndyUM357 avatar Feb 03 '15 17:02 AndyUM357

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.

peacechen avatar May 01 '15 14:05 peacechen

/bump :+1:

Xiphe avatar May 18 '15 09:05 Xiphe

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?

bensquire avatar May 20 '15 13:05 bensquire

Hello this issue continues, I solve calling a different config file in the task watch I like run multiCapabilities. Wait a better solution....

Luisangonzalez avatar Jun 09 '15 14:06 Luisangonzalez

I want this too, because I'd like to have my config in the gruntfile.

PhilippSoehnlein avatar Aug 14 '15 14:08 PhilippSoehnlein

See PR https://github.com/teerapap/grunt-protractor-runner/pull/131

t0mtaylor avatar Aug 20 '15 13:08 t0mtaylor

Thanks for working on this, t0mtaylor!

peacechen avatar Aug 20 '15 13:08 peacechen

how can we add max duration to load a page completely?

bcsf11a041 avatar Sep 28 '16 07:09 bcsf11a041

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

nmilosevic avatar Mar 14 '18 11:03 nmilosevic