简体   繁体   中英

How to loop in Protractor config file?

I am new to JS and Protractor for testing functionalities. 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.

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: function() {
    // TODO: check platform and return list of capability objects
},

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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