我可以访问我的量角器配置文件参数? [英] Can I access parameters in my protractor configuration file?

查看:212
本文介绍了我可以访问我的量角器配置文件参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行开始我量角器测试如下:

I start my protractor tests by running the following:

protractor protractor.conf.js --params.baseUrl=http://www.google.com --suite all

我想运行一个发射前'功能,该功能取决于一个参数(在这种情况下,的baseUrl)。难道这可能吗?

I would like to run a 'before launch' function which is dependant of one parameter (in this case, the baseUrl). Is it that possible?

exports.config = {
    seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar',
    seleniumPort: 4455,
    suites: {
        all: 'test/*/*.js',
    },
    capabilities: {
        'browserName': 'firefox'
    },
    beforeLaunch: function() {
        console.log('I want to access my baseUrl parameter here: ' + config.params.baseUrl);
    },
    onPrepare: function() {

        require('jasmine-reporters');
        jasmine.getEnv().addReporter(
            new jasmine.JUnitXmlReporter('output/xmloutput', true, true));

    }
};

如果我跑,我得到的ReferenceError因为配置没有定义。我应该怎么办呢?是,即使可能吗?

If I run that I get a ReferenceError because config is not defined. How should I do that? Is that even possible?

推荐答案

我不能完全肯定,如果量角器全局设置在 beforeLaunch()的阶段,但他们绝对可以在上prepare()一步。

I am not completely sure if protractor globals are set at the beforeLaunch() stage, but they are definitely available at onPrepare() step.

访问 PARAMS 对象:

console.log(browser.params.baseUrl);

这篇关于我可以访问我的量角器配置文件参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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