Headless protractor not sharding tests

亡梦爱人 提交于 2020-01-04 05:21:10

问题


I am trying to run my tests headless and shard both my test suites to run them in parallel. On my local machine they run in parallel but in this headless setup they run one after the other. I am using docker images for the web driver and protractor.

I am using webnicer-protractor docker image: https://hub.docker.com/r/webnicer/protractor-headless/ and using elgalu/selenium for the web driver.

My conf.js that I run looks like this:

exports.config = {
  //Headless
  //seleniumAddress: 'http://localhost:4444/wd/hub',
  seleniumAddress: 'http://localhost:24444/wd/hub',
  capabilities: {
    browserName: 'chrome',
    shardTestFiles: true,
    maxInstances: 2
  },
  specs: ['Suites/AccountSettingsSuite.js', 'Suites/CloneDashboardSuite.js']
}

回答1:


Protractor headless testing on real Google Chrome browser is now possible since Chrome >= 57, Chromedriver >= 2.29 along some basic config:

capabilities: {
    browserName: 'chrome',
    chromeOptions: {
        args: ['headless', 'window-size=1920,1080']
    }
}

Another cool thing is that the windows size is not limited to the current display, is truly headless meaning in can be as large as needed for the tests.

Some webdriver features won't work there, for instance:

browser.manage().window().setPosition();
browser.manage().window().setSize();
browser.manage().window().maximize();

You will have to identify and remove the unsupported features, other than that chrome headless is working great for me.

It's important to note that for example sendKeys might trigger this error:

Failed: unknown error: an X display is required for keycode conversions, consider using Xvfb

If there is no real display or there is no Xvfb until this is fixed on Chrome side.

UPDATE The X display required error is fixed with ChromeDriver 2.31



来源:https://stackoverflow.com/questions/37030486/headless-protractor-not-sharding-tests

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