Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Added support for multiCapabilities object and splitTestsBetweenCapabilities boolean #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rrazey
Copy link

@rrazey rrazey commented May 23, 2014

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.

…ilities boolean which were recently added to protractor
@teerapap
Copy link
Owner

@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

@rrazey
Copy link
Author

rrazey commented May 24, 2014

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.

@lovacuzitu
Copy link

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?

@rrazey
Copy link
Author

rrazey commented May 27, 2014

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

angular/protractor#492
angular/protractor#605

@Brootux
Copy link

Brootux commented May 28, 2014

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

@rrazey
Copy link
Author

rrazey commented May 28, 2014

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

@Brootux
Copy link

Brootux commented Jun 2, 2014

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)

@nowells
Copy link

nowells commented Jun 20, 2014

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

@Brootux
Copy link

Brootux commented Jul 17, 2014

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
Copy link

Brootux commented Jul 17, 2014

@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

@hilnius
Copy link

hilnius commented Sep 15, 2014

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 ?

@teerapap
Copy link
Owner

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

@Brootux
Copy link

Brootux commented Sep 17, 2014

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

@AndyUM357
Copy link

Any updates on this feature?

@peacechen
Copy link

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.

@Xiphe
Copy link

Xiphe commented May 18, 2015

/bump 👍

@bensquire
Copy link

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?

@Luisangonzalez
Copy link

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

@PhilippSoehnlein
Copy link

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

@t0mtaylor
Copy link

See PR #131

@peacechen
Copy link

Thanks for working on this, t0mtaylor!

@bcsf11a041
Copy link

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

@nmilosevic
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.