Saturday, November 2, 2019

Getting Data From Protractor Configuration File

Step 1 :

We need to use the following params section under config.js


// An example configuration file.
exports.config = {
  directConnect: true,

  // Capabilities to be passed to the webdriver instance.
  capabilities: {
    'browserName': 'chrome'
  },
  params:{
    paramData1: 'Test Param Data 1',
    paramData2: 'Test Param Data 2'
  },
  // Framework to use. Jasmine is recommended.
  framework: 'jasmine',
  baseUrl:'https://www.google.com',
  // Spec patterns are relative to the current working directory when
  // protractor is called.
  specs: ['../testsjs/google_spec.js'],

  // Options to be passed to Jasmine.
  jasmineNodeOpts: {
    defaultTimeoutInterval: 30000
  },

  
};



Step 2 :

We can access those data from our specs file using the following code


        console.log(browser.params.paramData1)
        console.log(browser.params.paramData2)

No comments:

Post a Comment