简体   繁体   English

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

[英]Protractor Define Spec In Config File

How can I accomplish the following with protractor?... What I am ultimately trying to do is have these specs built in a "specBuilder.js" in node and then pass them in the config file... Trying to figure out the best possible way to do this. 我如何用量角器完成以下工作?...我最终想要做的是将这些规格内置在节点的“ specBuilder.js”中,然后将其传递到配置文件中...试图找出最好的规格可行的方法。

Trying to achieve syntax like the following 尝试实现如下语法

https://github.com/angular/protractor/blob/master/docs/api-overview.md https://github.com/angular/protractor/blob/master/docs/api-overview.md

// 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.
    }
};

The solution I found to this was providing one spec file so for instance specBuilder.js . 我发现的解决方案是提供一个规范文件,例如specBuilder.js Then within this file you can programmatically define the rest of your tests by using loops and requires. 然后,在此文件中,您可以使用循环和需求以编程方式定义其余测试。

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

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