简体   繁体   English

AngularJS&Protractor和Jasmine-所有规格的全局变量

[英]AngularJS & Protractor & Jasmine - global variable for all specs

My config.js looks like this 我的config.js看起来像这样

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['test1.js', 'test2.js'],
  framework: 'jasmine2'
};

As you can see I have 2 test files, what I want to do is to use a single variable across all the specs. 如您所见,我有2个测试文件,我要做的是在所有规格中使用单个变量。

How can I achieve it ? 我该如何实现?

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

    specs: [
        'spec1.js',
        'specs2.js'
    ],
    params: {
        screenWidth: 1920,
        screenHeight: 1080
    }
}

in order to access variable you should do smth like this in your specs: 为了访问变量,您应该在规格中执行以下操作:

browser.params.screenWidth

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

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