Is there a way to run protractor tests in parallel by opening a browser instance for each test?

吃可爱长大的小学妹 提交于 2019-12-07 00:33:24

问题


I am facing synchronisation issues with my protractor tests and I would like to run my tests in parallel in contrast to my actual settings. In fact at the moment my tests run one after the other. I know how to this with TestsNG not sure how to do it with Jasmin Framework?


回答1:


Since 0.19.0 version of Protractor, you can run tests in parallel using the multiCapabilities option:

protractor.conf.js

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

from Browser setup - Protractor docs

This issue seems to fit your case.

For now, Protractor doesn't allow to set Webdriver maxSessions option, there is a more global discussion to include this feature among others.

EDIT: multiCapabilities was introduced to run tests in parallel under different browsers, but in your case, you can use it to run multiple instances of the same ;)




回答2:


To split tests between two browsers,

  capabilities: {
    browserName: 'chrome',
    shardTestFiles: true,
    maxInstances: 2
  },



回答3:


multiCapabilities: [
    {
        "browserName": "chrome",        
        shardTestFiles: true,
        maxInstances: 2,
        specs: ['login.js', 'login2.js', 'login.js', 'login2.js']
    },
    {
        "browserName": "firefox",
        "count": 1
        specs: ['login2.js']
    },
],

You can use both "count" as well "maxInstances" This is what worked best for me ..

            "browserName": "chrome",        
            shardTestFiles: true,
            maxInstances: 2,
            specs: ['login.js', 'login2.js', 'login.js', 'login2.js']

this would run 4 tests divided equally(or may not equally) in two different chrome browsers.



来源:https://stackoverflow.com/questions/22199711/is-there-a-way-to-run-protractor-tests-in-parallel-by-opening-a-browser-instance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!