量角器中的`exports.config`是什么?

时间:2017-05-23 12:22:19

标签: protractor

  

量角器配置文件#

     

量角器中exports.config是什么?

3 个答案:

答案 0 :(得分:3)

你这么说:exports.config = {...}

用于全局变量和测试的配置。

例如:

exports.config = {
  seleniumAddress: "http://127.0.0.1:4444/wd/hub",
  baseUrl: "localhost:8080"
}]

更多:https://github.com/angular/protractor/blob/master/docs/tutorial.md

答案 1 :(得分:1)

Protractor中的

exports.config用于指定conf.js中的配置,如下所示:

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

  // define browser capabilities
  capabilities: {
     browserName: 'chrome',
     chromeOptions: {
        args: [
             '--disable-extensions',
            ]
    }
 },
  // Define which tests should execute.
  specs: ['test-spec.js']

 // set log level
 logLevel: 'verbose',
 // Enables colors for log output
 coloredLogs: true,
};

使用的默认框架是Jasmine,运行测试使用下面的命令

     protractor conf.js

答案 2 :(得分:0)

export.config {.....}

这是我们定义/配置框架详细信息,selenium详细信息,规范,脚本超时,Onprepare功能,功能,报告和所有通用内容的地方。

一旦Run开始,量角器首先查找此文件并尝试在此处执行这些操作。 例如,启动selenium web-driver实例,打开浏览器等。

EG)

    exports.config = {
    framework: 'jasmine2',      //framework Used
    seleniumPort: 4444,         // selenium port address
   //seleniumAddress: 'http://localhost:4444/wd/hub',

    specs: ['./Spec/Master.spec.js'],  /*Spec -> consists of test suite/ test cases  */
allScriptsTimeout: 50000,
jasmineNodeOpts: {                   //jasmine framework details
    isVerbose: true,
    showColors: true,
    includeStackTrace: true,
    defaultTimeoutInterval: 300000,
    print: function() {}
},
capabilities:                  //Browser details against which test runs
    {
        'browserName' :'chrome',
        'chromeOptions' : {
            'args':['incognito','--start-maximized'],  /*this line is for maximize the window and incognito view */
            prefs: {
                'profile:managed_default_content_settings.notifications': 1
            }
        }

    },
      //before starting the 
      actual TC execution, setup the things we define here

   onPrepare: function (config_) {            
    require('./Data/waitReady.js');
    //browser.manage().window().maximize();

    var jasmineReporters = require('jasmine-reporters');
    jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
        consolidateAll: false,
        savePath: './Reports/JunitXMLprotractor-result/',
        filePrefix: 'xmloutput'
    }));

    jasmine.getEnv().addReporter(
        new Jasmine2HtmlReporter({
            savePath: './Reports/Screenshots/',
            takeScreenshots: true,
            takeScreenshotsOnlyOnFailures: true,
            consolidateAll: true,
            showPassed: true,
            // filePrefix: sessionId + 'AutomationReport',
            filePrefix: 'AutomationReport',
            cleanDestination: true,
        })
    );


    global.isAngularSite = function(flag){
        browser.driver.ignoreSynchronization = !flag;
    };