简体   繁体   English

如何在Protractor配置文件中循环?

[英]How to loop in Protractor config file?

I am new to JS and Protractor for testing functionalities. 我是JS和Protractor的新手,用于测试功能。 I need to include some conditions or loops inside 'Configuration' file of protractor. 我需要在量角器的“配置”文件中包含一些条件或循环。 Such as, if I need to check my specs running on 'Windows / Mac' platform and a variable provides these details. 例如,如果我需要检查在“Windows / Mac”平台上运行的规范,并且变量提供了这些详细信息。

I am expecting something like : 我期待的是:

exports.config = {
    seleniumAddress : 'http://localhost:4444/wd/hub',
    getPageTimeout : 30000,
    allScriptsTimeout : 30000,
    specs : [  ],
    framework : 'jasmine2',

    ***don't know the syntax, am expecting below line and condition need to work for protractor***
    ***var platform = 'Windows',
    if(platform ==='Windows'){***
    multiCapabilities: [{
        'browserName': 'chrome',
        'specs': ['spec1.js']
      },
      ***else {***
        'browserName': 'chrome',
        'specs': ['spec2.js']
      }],
};

Is it possible to validate in Configuration file? 是否可以在配置文件中验证?

You need to use the getMultiCapabilities function : 您需要使用getMultiCapabilities函数

getMultiCapabilities: function() {
    // TODO: check platform and return list of capability objects
},

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM