Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running e2e tests using Protractor multiCapabilities config but limit max Webdriver instances

Context

I am trying the brand new Protractor 0.19.0 with the multiCapabilities config option. It is actually working as described in the docs :

  1. It makes running tests on multiple browsers easier (no need for grunt, nor script, only 1 config file).
  2. It makes tests running in parallel

The second point is problematic for me. One of my app doesn't handle multiple connection to the data, implying that the tests fail.

My question is:

Is it possible to limit the maximum number of instances of Webdriver in order to disable parallel testing for this app?

What I have tried

I've found in Selenium Webdriverjs Grid2 wiki that there's a maxSession parameter that would perfectly fit to my case! But I tried to add it in my Protractor config, without success.

maxSession is also in the Desired Capabilities. Anyone knows if it's working yet?

Here is the link to the multiCapabilities PR topic, I left a comment there.

If you need more info, feel free to ask :)

Thanks in advance!!

EDIT: Dedicated GitHub issue

EDIT2: I recently tried to add seleniumArgs: ['-maxSession=1'] to my Protractor config, unfortunaltely this doesn't work too...

like image 355
glepretre Avatar asked Feb 25 '14 09:02

glepretre


2 Answers

Implemented in this commit and released in 0.24.0 (See Protractor changelog).

You need to add a maxSessions option into your protractor config file with a value >=1 (otherwise it is considered as unlimited).

protractor.config.js example:

exports.config = {
  seleniumAddress: 'http://127.0.0.1:4444/wd/hub',

  specs: [
    '../e2e/**/*.js'
  ],

  multiCapabilities: [
    {'browserName': 'chrome'},
    {'browserName': 'firefox'},
    {'browserName': 'phantomjs'}
  ],

  maxSessions: 1,

  baseUrl: 'http://localhost:8000'
};

Tested and working as expected for my case.

like image 195
glepretre Avatar answered Nov 17 '22 22:11

glepretre


I think you can set this by launching selenium nodes in command line and by giving:

MaxInstances This says....how many instances of same version of browser can run over the Remote System.

or

MaxSession This says....how many browsers (Any Browser and any version) can run in parallel at a time in the remote system. So this overrides the Max Instances settings and can restrict the number of browser instances that can run in parallel.

from this answer

So you will run your node as such :

java -jar selenium-server-standalone-2.14.0.jar -role node  -hub http://******:4444/grid/register -maxSession 5 
like image 35
Ziwdigforbugs Avatar answered Nov 17 '22 20:11

Ziwdigforbugs