量角器 - 在不同的浏览器上并行运行多个测试

ten*_*ent 35 selenium-grid angularjs protractor

我找不到任何关于如何设置它的信息,但它似乎是一个非常基本的概念,所以我确信那里有一个答案.

我知道如何通过在配置中设置对象的browserName属性来在不同的浏览器上运行量角器capabilities.而且这很有效.我可以将它设置为'chrome'或者'firefox'我需要的任何东西,它运行正常.但是,针对多个浏览器运行单个测试套件的唯一方法(据我所知)是创建单独的配置文件,每个配置文件都有不同的browserName,然后使用自己的配置运行每个浏览器.这可行,但它真的很慢,因为测试然后按顺序运行,而不是同时运行.

有没有办法在多个浏览器上并行运行它?

可以在SauceLabs上完成吗?甚至使用当地的Selenium-Grid?

我们只是想简化我们的测试流程,这将是一个巨大的帮助.任何建议或信息将不胜感激.提前致谢.

Pao*_*tti 64

有一个新的选项要求multiCapabilities:

multiCapabilities: [{
  'browserName': 'chrome'
}, {
  'browserName': 'firefox'
}],
Run Code Online (Sandbox Code Playgroud)

这是一个完整的例子.


Bri*_*n F 22

2014年2月更新 - 此答案不再有效.请使用Paolo Moretti的答案.


可能有更好的方法来做到这一点,但目前我只是将它们作为并发的Grunt任务执行.

1)添加grunt并发插件

npm install grunt-concurrent --save-dev
Run Code Online (Sandbox Code Playgroud)

2)在grunt.initConfig下为每个浏览器添加一个任务.我们可以将浏览器添加为arg以重用我们的配置文件.

protractor: {
        options: {
            keepAlive: true,
            singleRun: false,
            configFile: "test/protractor.conf.js"
        },
        run_chrome: {
            options: {
                args: {
                    browser: "chrome"
                }
            }
        },
        run_firefox: {
            options: {
                args: {
                    browser: "firefox"
                }
            }
        }
    },
Run Code Online (Sandbox Code Playgroud)

3)将这些作为任务注册;

grunt.registerTask('protractor-chrome', ['protractor:run_chrome']);
grunt.registerTask('protractor-firefox', ['protractor:run_firefox']);
Run Code Online (Sandbox Code Playgroud)

4)在grunt.initConfig下创建并发任务

concurrent: {
        protractor_test: ['protractor-chrome', 'protractor-firefox']
    },
Run Code Online (Sandbox Code Playgroud)

5)为并发添加grunt任务

grunt.registerTask('protractor-e2e', ['concurrent:protractor_test']);
Run Code Online (Sandbox Code Playgroud)

执行它应该给你并发量角器测试.


Pau*_*aul 14

using multiCapabilities将在每个浏览器中运行所有测试.因此,下面的配置将每次测试运行两次,一次在Firefox中,一次在Chrome中:

multiCapabilities: [{
  'browserName': 'chrome'
}, {
  'browserName': 'firefox'
}],
Run Code Online (Sandbox Code Playgroud)

如果您希望每个测试文件只运行一次,但在多个浏览器之间拆分,则使用以下splitTestsBetweenCapabilities选项:

splitTestsBetweenCapabilities: true
Run Code Online (Sandbox Code Playgroud)

这篇博文详细介绍了这篇文章splitTestsBetweenCapabilities