Javascript 量角器在配置文件中定义规格

Javascript 量角器在配置文件中定义规格,javascript,angularjs,protractor,Javascript,Angularjs,Protractor,如何使用量角器完成以下操作?。。。我最终要做的是将这些规范构建在节点中的“specBuilder.js”中,然后将它们传递到配置文件中。。。试图找出最好的方法来做到这一点 尝试实现如下语法 //示例配置文件 exports.config={ //正在运行的selenium服务器的地址。 赛琳娜的裙子:'http://localhost:4444/wd/hub', //要传递给webdriver实例的功能。 能力:{ 'browserName':'chrome' }, //等级库模式与传递的配置

如何使用量角器完成以下操作?。。。我最终要做的是将这些规范构建在节点中的“specBuilder.js”中,然后将它们传递到配置文件中。。。试图找出最好的方法来做到这一点

尝试实现如下语法

//示例配置文件
exports.config={
//正在运行的selenium服务器的地址。
赛琳娜的裙子:'http://localhost:4444/wd/hub',
//要传递给webdriver实例的功能。
能力:{
'browserName':'chrome'
},
//等级库模式与传递的配置文件位置相关
//到量角器(在本例中为conf.js)。
//它们可能包括glob模式。
规格:[
函数(){
描述('angularjs主页',函数(){
它('应该问候指定用户',函数(){
//加载AngularJS主页。
browser.get('http://www.angularjs.org');
//查找ng模型与“yourName”匹配的元素-这将
//找到元素-然后
//在里面输入“朱莉”。
元素(by.model('yourName')).sendKeys('Julie');
//查找绑定与“yourName”匹配的元素-这将
//查找Hello{{yourName}}!元素。
var greeting=element(by.binding('yourName');
//断言文本元素具有预期值。
//量角器补丁“期望”理解承诺。
expect(greeting.getText()).toEqual('Hello Julie!');
});
});
},
函数(){
描述('angularjs主页',函数(){
它('应该问候指定用户',函数(){
//加载AngularJS主页。
browser.get('http://www.angularjs.org');
//查找ng模型与“yourName”匹配的元素-这将
//找到元素-然后
//在里面输入“朱莉”。
元素(by.model('yourName')).sendKeys('Julie');
//查找绑定与“yourName”匹配的元素-这将
//查找Hello{{yourName}}!元素。
var greeting=element(by.binding('yourName');
//断言文本元素具有预期值。
//量角器补丁“期望”理解承诺。
expect(greeting.getText()).toEqual('Hello Julie!');
});
});
}
],
//要传递给Jasmine节点的选项。
茉莉花:{
showColors:true,//在命令行报告中使用颜色。
}
};

我找到的解决方案是提供一个spec文件,例如
specBuilder.js
。然后在此文件中,您可以通过使用循环和requires以编程方式定义其余的测试

// An example configuration file
exports.config = {
    // The address of a running selenium server.
    seleniumAddress: 'http://localhost:4444/wd/hub',

    // Capabilities to be passed to the webdriver instance.
    capabilities: {
        'browserName': 'chrome'
    },

    // Spec patterns are relative to the configuration file location passed
    // to protractor (in this example conf.js).
    // They may include glob patterns.
    specs: [
        function(){
            describe('angularjs homepage', function() {
                it('should greet the named user', function() {
                    // Load the AngularJS homepage.
                    browser.get('http://www.angularjs.org');

                    // Find the element with ng-model matching 'yourName' - this will
                    // find the <input type="text" ng-model="yourName"/> element - and then
                    // type 'Julie' into it.
                    element(by.model('yourName')).sendKeys('Julie');

                    // Find the element with binding matching 'yourName' - this will
                    // find the <h1>Hello {{yourName}}!</h1> element.
                    var greeting = element(by.binding('yourName'));

                    // Assert that the text element has the expected value.
                    // Protractor patches 'expect' to understand promises.

                    expect(greeting.getText()).toEqual('Hello Julie!');
                });
            });
        },
        function(){
            describe('angularjs homepage', function() {
                it('should greet the named user', function() {
                    // Load the AngularJS homepage.
                    browser.get('http://www.angularjs.org');

                    // Find the element with ng-model matching 'yourName' - this will
                    // find the <input type="text" ng-model="yourName"/> element - and then
                    // type 'Julie' into it.
                    element(by.model('yourName')).sendKeys('Julie');

                    // Find the element with binding matching 'yourName' - this will
                    // find the <h1>Hello {{yourName}}!</h1> element.
                    var greeting = element(by.binding('yourName'));

                    // Assert that the text element has the expected value.
                    // Protractor patches 'expect' to understand promises.

                    expect(greeting.getText()).toEqual('Hello Julie!');
                });
            });
        }
    ],

    // Options to be passed to Jasmine-node.
    jasmineNodeOpts: {
        showColors: true, // Use colors in the command line report.
    }
};