Storing global variable in a separate file for Protractor Tests

前端 未结 1 1968
谎友^
谎友^ 2021-01-23 12:49

I am trying to create a separate inventory file for Protractor Test where I can store all the reusable variable to be used by different test scrips. The sample Variable list is

相关标签:
1条回答
  • 2021-01-23 13:26

    The below approach should work for you.

    conf.js

    exports.config = {
      framework: 'jasmine',
      seleniumAddress: 'http://localhost:4444/wd/hub',
      specs: ['app.js'],
      onPrepare: async() => {
          global.globalVariables = require('./globalVariables');
      }
    };
    

    app.js

    describe('desribe the test', () => {
      it('the it', async () => {
          console.log(globalVariables.loginMain);
          console.log(globalVariables.TestText);
      })
    })
    

    globalVariables.js

    module.exports = {
      loginMain :'https://mytestsite.com/auth/login',
      TestText : 'I am the test Text'
    }
    
    0 讨论(0)
提交回复
热议问题