Protractor有getConfig()吗?

时间:2015-06-01 20:26:32

标签: protractor

我有以下config.js文件:

var testName = 'Testing';
var HtmlReporter = require('protractor-html-screenshot-reporter');
var reporter = new HtmlReporter({
    baseDirectory: './protractor-result', // a location to store screen shots.
    docTitle: 'Report Test Summary',
    docName: 'protractor-tests-report.html'
});
exports.config = {

    seleniumAddress: 'http://hub.browserstack.com/wd/hub',
    multiCapabilities: [

        {
            name: testName,
            browserName: 'Chrome',
            browser_version: '39.0',
            os: 'OS X',
            os_version: 'Yosemite',
            resolution: '1920x1080',
            'browserstack.user': browserstackUser,
            'browserstack.key': browserstackKey,
            'browserstack.debug': 'true',
            'browserstack.selenium_version': '2.45.0'
        }
        ,
        {
            name: testName,
            browserName: 'IE',
            browser_version: '11.0',
            os: 'Windows',
            os_version: '8.1',
            resolution: '2048x1536',
            'browserstack.user': browserstackUser,
            'browserstack.key': browserstackKey,
            'browserstack.debug': 'true',
            'browserstack.selenium_version': '2.45.0',
            'browserstack.ie.driver': '2.44',
            //ignoreProtectedModeSettings: true
        }
    ],

    // Spec patterns are relative to the current working directly when
    // protractor is called.

    suites: {
        waitlist: './././specs/waitlist_page_spec.js',
        press: './././specs/press_page_spec.js',
        news: './././specs/news_page_spec.js',
        landing: './././specs/landing_page_spec.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: 2,

    // protractor will save the test output in json format at this path.
    // The path is relative to the location of this config.
    resultJsonOutputFile: null,

    framework: 'jasmine2',

    // Options to be passed to Jasmine-node.
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 100000,
        realtimeFailure: true,
        showTiming: true,
        includeStackTrace: true,
        isVerbose: true,
        onComplete: null
    },

    onPrepare: function () {
        jasmine.getEnv().addReporter(reporter);
        browser.driver.manage().window().maximize();
        global.dvr = browser.driver; //variable to call selenium directly
        global.isAngularSite = function (flag) {
            browser.ignoreSynchronization = !flag; //This setup is to configure when testing non-angular pages
        };
        //browser.manage().timeouts().pageLoadTimeout(90000);
        browser.manage().timeouts().implicitlyWait(100000);

    }

};

我想找到一种方法来询问我的测试,如果capability.browserName是IE做某个/特殊的动作,那么,我想做某种getConfig(),这可能吗?有没有人实现类似的东西?

谢谢大家的时间!

1 个答案:

答案 0 :(得分:1)

浏览器中的getCapabilities返回带有以下值的promise:

browser.getCapabilities().then(function (capabilities) {
    browser = capabilities.caps_.browserName;
    platform = capabilities.caps_.platform;
}).then(function displayEnv() {
    console.log('Browser:', browser, 'on platform', platform);
});