使用 Protractor multiCapabilities 配置运行 e2e 测试,但限制最大 Webdriver 实例 [英] Running e2e tests using Protractor multiCapabilities config but limit max Webdriver instances

查看:27
本文介绍了使用 Protractor multiCapabilities 配置运行 e2e 测试,但限制最大 Webdriver 实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

我正在尝试带有 multiCapabilities 配置选项的全新量角器 0.19.0.它实际上按照文档中的描述工作:

I am trying the brand new Protractor 0.19.0 with the multiCapabilities config option. It is actually working as described in the docs :

  1. 它使在多个浏览器上运行测试变得更容易(不需要 grunt,也不需要脚本,只有 1 个配置文件).
  2. 它使测试并行运行

第二点对我来说是有问题的.我的一个应用程序无法处理多个数据连接,这意味着测试失败.

The second point is problematic for me. One of my app doesn't handle multiple connection to the data, implying that the tests fail.

我的问题是:

是否可以限制 Webdriver 的最大实例数以禁用此应用的并行测试?

Is it possible to limit the maximum number of instances of Webdriver in order to disable parallel testing for this app?

我的尝试

我在 Selenium Webdriverjs Grid2 wiki 中发现有一个 maxSession 完全适合我的情况的参数!但是我尝试将它添加到我的量角器配置中,但没有成功.

I've found in Selenium Webdriverjs Grid2 wiki that there's a maxSession parameter that would perfectly fit to my case! But I tried to add it in my Protractor config, without success.

maxSession 也在 DesiredCapabilities 中.有人知道它是否有效吗?

maxSession is also in the Desired Capabilities. Anyone knows if it's working yet?

这是 multiCapabilities PR 主题的链接,我在那里发表了评论.

Here is the link to the multiCapabilities PR topic, I left a comment there.

如果您需要更多信息,请随时询问:)

If you need more info, feel free to ask :)

提前致谢!!

专用 GitHub 问题

我最近尝试将 seleniumArgs: ['-maxSession=1'] 添加到我的量角器配置中,不幸的是这也不起作用......

I recently tried to add seleniumArgs: ['-maxSession=1'] to my Protractor config, unfortunaltely this doesn't work too...

推荐答案

this 中实施提交并在 0.24.0 中发布(参见 Protractor changelog).

Implemented in this commit and released in 0.24.0 (See Protractor changelog).

您需要在量角器配置文件中添加一个 maxSessions 选项,其值 >=1(否则为 被认为是无限制的).

You need to add a maxSessions option into your protractor config file with a value >=1 (otherwise it is considered as unlimited).

protractor.config.js 示例:

exports.config = {
  seleniumAddress: 'http://127.0.0.1:4444/wd/hub',

  specs: [
    '../e2e/**/*.js'
  ],

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

  maxSessions: 1,

  baseUrl: 'http://localhost:8000'
};

针对我的案例进行了测试并按预期工作.

Tested and working as expected for my case.

这篇关于使用 Protractor multiCapabilities 配置运行 e2e 测试,但限制最大 Webdriver 实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆