配置与承诺多种功能 [英] Configuring multiple capabilities with promises

查看:184
本文介绍了配置与承诺多种功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个后续的设置Firefox的配置与量角器的话题。

This is a follow-up to the Set firefox profile with protractor topic.

按照 setFirefoxProfile howto中,有可能设置一个Firefox配置文件与特殊的帮手JS code,它使用 Firefox的知名度 q 库,使动态连接codeD Firefox的配置。

According to the setFirefoxProfile howto, it is possible to set a firefox profile with a special "helper" js code which uses firefox-profile and q libraries to make an encoded firefox profile on the fly.

这为我工作,直到我试过的使用多个浏览器和配置<一href=\"https://github.com/angular/protractor/blob/master/docs/browser-setup.md#testing-against-multiple-browsers\"相对=nofollow> multiCapabilities 的:

This worked for me until I've tried to use multiple browsers and configuring multiCapabilities:

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

    multiCapabilities: [
        {
            browserName: 'chrome',
            specs: [
                'footer.disabledCookies.spec.js'
            ],
            chromeOptions: {
                prefs: {
                    'profile.default_content_settings.cookies': 2
                }
            }
        },

        ...
        // other capabilities here
        ...

        helper.getFirefoxProfile()    
     },

     ...
}

有了这个设置,我得到一个错误(全追踪这里):

规格模式不匹配的任何文件。

Spec patterns did not match any files.

据我了解,这意味着与Firefox配置文件设置缺少规格键。换句话说,它找不到任何测试运行

As I understand, this means that the setup with firefox profile is missing specs key. In other words, it cannot find any tests to run.

我试过包括规格进入功能词典助手自己里面,但错误依然存在。

I've tried to include specs into the capabilities dictionary inside the helper itself, but the error persists.

如何修复错误,并设置Firefox配置文件,如果使用 multiCapabilities

How to fix the error and set firefox profile if using multiCapabilities?

作为一种变通方法,我创建只有Firefox的一个单独的量角器配置文件来配置(使用功能),并设置咕噜运行两次量角器 - 一个用于这个火狐配置文件的配置,另外一个是对所有其他浏览器

As a workaround, I've created a separate protractor configuration file with only firefox configured (using capabilities) and set grunt to run protractor twice - one for this "firefox with a profile" config and the other one for all other browsers.

推荐答案

目前,量角器可如果我们不使用multicapabilities只接受承诺的能力。这样做的原因是因为multiCapabilities运行在一个新的进程的每个任务,所以承诺(功能)不能被传递(单能力的工作,因为我们不分叉)。

Right now, protractor can only accept promise as capabilities if we are NOT using multicapabilities. The reason for this is because multiCapabilities runs each task in a new process, so the promise (function) cannot be passed (single capabilities work because we're not forking).

另外,我们可以在发射解决能力,通过了解决功能整合到新流程之前;然而,这将中断设置代理的能力( https://github.com/angular/protractor /拉/ 1040 ),这依赖于能力的承诺driverProvider设置后得到解决。

Alternatively we could resolve capabilities in the launcher, before passing the resolved capabilities into the new processes; however, this will break the ability to set up proxies (https://github.com/angular/protractor/pull/1040), which relies on capability promises to be resolved after driverProvider setup.

我想不出这样做(没有大的重构)的一个简单的方法,但它肯定是可行的。
我创建了一个问题的量角器( https://github.com/angular/protractor/issues/1594 )。请按照和/或发表评论,如果这是你需要的东西,或者你有其他的想法来实现它。

I can't think of an easy way of doing this (without large refactoring), but it is definitely doable. I created an issue for Protractor (https://github.com/angular/protractor/issues/1594). Please follow that and/or comment on it if this is something you need or you have other ideas to implement it.

现在,你将需要使用你在原来的问题中提到的解决方法。

For now you would need to use the workaround you mentioned in your original question.

更新

https://github.com/angular/protractor/pull/1629 支持这个。在量角器1.6(或者,如果同步到主),你可以在一个函数传递给 config.getMultiCapabilities 上prepare onCleanup 。此功能可以返回一个承诺 multiCapabilties (即功能阵列)。

https://github.com/angular/protractor/pull/1629 supports this. Starting in protractor 1.6 (or if you sync to master) you can pass in a function to config.getMultiCapabilities like onPrepare and onCleanup. This function can return a promise to multiCapabilties (i.e. array of capabilities).

请参阅 https://github.com/angular/protractor/blob /master/spec/getCapabilitiesConf.js 一个例子。

这篇关于配置与承诺多种功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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