如何在量角器中按顺序运行多浏览器测试
How to run multi browser tests sequentially in Protractor?
例如,我有5个tc,需要在Firefox和Chrome上运行所有5个测试用例。因此,一旦Chrome完成了5个tc的执行,我需要Firefox浏览器启动并依次执行相同的任务。
当我使用multiCapabilities时,它会同时启动Firefox和Chrome。
您可以在量角器配置中使用maxSessions
变量conf.js
// Maximum number of total browser sessions to run. Tests are queued in
// sequence if number of browser sessions is limited by this parameter.
// Use a number less than 1 to denote unlimited. Default is unlimited.
maxSessions: -1
更多信息https://github.com/angular/protractor/blob/master/docs/referenceConf.js#L198
示例conf.js
(firefox, safari, chrome, chrome设备模拟器):
multiCapabilities: [
{
browserName: 'firefox'
},
{
browserName: 'safari'
},
{
browserName: 'chrome'
},
{
browserName: 'chrome',
// List of devices https://cs.chromium.org/chromium/src/chrome/test/chromedriver/chrome/mobile_device_list.cc
'deviceName': 'Google Nexus 5'
},
{
browserName: 'chrome',
'deviceName': 'Apple iPhone 6'
},
{
browserName: 'chrome',
'deviceName': 'Apple iPad'
},
{
browserName: 'chrome',
'deviceName': 'Samsung Galaxy S4'
}
],
maxSessions: 1
更多的例子和测试在实际设备https://github.com/aluzardo/protractor-cucumber-tests
这已经在量度器版本5.4.2中进行了测试并正常工作,并且根据Adolfo的答案,我添加了maxSessions: 1,因此它以顺序模式运行。换句话说,firefox规范首先被执行,然后才是chrome。
exports.config = {
framework: 'jasmine',
directConnect: false,
multiCapabilities: [{
browserName: 'firefox',
'moz:firefoxOptions': {
args: ['--verbose'],
binary: 'C:/Program Files/Mozilla Firefox/firefox.exe'
//Need to start cmd via admin mode to avoid permission error
},
specs: ['src/com/sam/scriptjs/draganddrop.spec.js']
},
{
browserName : 'chrome',
chromeOptions: {
args: [ "--start-maximized" ]
},
specs: ['src/com/sam/scriptjs/iframes.spec.js']
}],
maxSessions: 1,//To run in sequential mode so first Firefox then chrome
//without max session it will open two windows at the same time for both browsers
seleniumAddress: 'http://localhost:4444/wd/hub'
}
相关文章:
- 如何使用phaser使html5游戏在移动设备浏览器上运行
- 多人游戏完全在浏览器中运行,服务器仅用于数据库
- 在禁用浏览器flash插件的情况下运行Karma测试
- 在浏览器检查表单之前运行javascript onsubmit
- 编写在浏览器和node.js中运行的模块化ECMAScript
- 使用浏览器在页面(客户端)上运行自定义JavaScript来模拟点击?怎么做
- 无法使用firefox在浏览器中运行此代码
- 通过运行条件编译防止JS泄露IE浏览器
- 我无法让脚本在不同的浏览器中正常运行
- 如何在浏览器中运行 Processing+Twitter4j sketch
- 在浏览器上显示实习运行程序功能测试的结果
- Apache Cordova:在不启动浏览器应用程序的情况下运行Cordova运行浏览器
- 在 Node.js 中运行浏览器 JS
- 是否可以在不运行浏览器的情况下在Visual Studio中调试JavaScript代码
- 在HTML5中,是相对于运行浏览器的用户帐户的本地存储
- 在node中运行浏览器javascript单元测试
- 运行浏览器特定的JavaScript
- 我如何在NodeJS中运行浏览器应用程序
- internet explorer -是否有办法通过javascript运行浏览器插件或附加命令
- 运行浏览器隐藏使用Php