Protractor - 在不同的浏览器上并行运行多个测试 [英] Protractor - run multiple tests in parallel on different browsers
问题描述
我找不到任何关于如何设置的信息,但这似乎是一个非常基本的概念,所以我相信那里有答案.
I can't find any information on how to set this up, but it seems like a pretty basic concept, so I'm sure there's an answer out there.
我知道如何通过在配置中设置 capabilities
对象的 browserName
属性在不同的浏览器上运行量角器.这很好用.我可以将它设置为 'chrome'
或 'firefox'
或任何我需要的东西,它会按预期运行.但是,针对多个浏览器(据我所知)运行单个测试套件的唯一方法是创建单独的配置文件,每个配置文件都有不同的 browserName
,然后使用自己的配置运行每个浏览器.这行得通,但它真的很慢,因为测试是按顺序运行的,而不是同时运行的.
I know how to run protractor on different browsers by setting the browserName
property of the capabilities
object in the config. And that's working great. I can set it to 'chrome'
or 'firefox'
or whatever I need and it runs just as expected. But the only way to run a single test suite against multiple browsers (as far as I know) is to create separate config files, each with a different browserName
and then run each browser with its own config. This works, but its really slow because tests are then running in sequence, rather than concurrently.
有没有办法在多个浏览器上并行运行?
Is there any way to run it on multiple browsers in parallel?
可以在 SauceLabs 上完成吗?甚至使用本地 Selenium-Grid?
Can it be done on SauceLabs? or even using a local Selenium-Grid?
我们只是想简化我们的测试过程,这将是一个巨大的帮助.任何建议或信息将不胜感激.提前致谢.
We are just trying to streamline our testing process and this would be a huge help. Any suggestions or info would be greatly appreciated. Thanks in advance.
推荐答案
2014 年 2 月更新 - 此答案不再有效.在下面使用 Paolo Moretti 的答案.
可能有更好的方法来做到这一点,但目前我只是将这些作为并发 Grunt 任务执行.
There may be a better way to do this but currently I am just executing these as concurrent Grunt tasks.
1) 添加 grunt 并发插件
1) Add the grunt concurrent plugin
npm install grunt-concurrent --save-dev
2) 在 grunt.initConfig 下为每个浏览器添加一个任务.我们可以将浏览器添加为 arg 以重用我们的配置文件.
2) Add a task for each browser under grunt.initConfig. We can add the browser as an arg to re-use our configuration file.
protractor: {
options: {
keepAlive: true,
singleRun: false,
configFile: "test/protractor.conf.js"
},
run_chrome: {
options: {
args: {
browser: "chrome"
}
}
},
run_firefox: {
options: {
args: {
browser: "firefox"
}
}
}
},
3) 将这些注册为任务;
3) Register these as tasks;
grunt.registerTask('protractor-chrome', ['protractor:run_chrome']);
grunt.registerTask('protractor-firefox', ['protractor:run_firefox']);
4) 在 grunt.initConfig 下创建并发任务
4) Create your concurrent task under grunt.initConfig
concurrent: {
protractor_test: ['protractor-chrome', 'protractor-firefox']
},
5) 为并发添加 grunt 任务
5) Add the grunt task for concurrent
grunt.registerTask('protractor-e2e', ['concurrent:protractor_test']);
执行它应该会给你并发量角器测试.
And executing that should give you concurrent protractor tests.
这篇关于Protractor - 在不同的浏览器上并行运行多个测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!