1

I'm trying to understand the order in which protractor executes according to the execution stack. What is the order in the execution stack after the global execution context (ec) is created and pushed? Is it?

     stack
    ------
    |spec1 ec|
    |spec2 ec|
    |spec3 ec|
    |onPrepare ec|
    |conf.js ec|
    |global ec|
    ----------

I'm really sure this is not correct because i'm just guessing here. Can someone shed some light on what execution context gets create and when? Thanks.

awaken
  • 789
  • 1
  • 11
  • 22

1 Answers1

0

I can Guide as per my knowledge as below:

Protractor calls conf.js as we write protractor conf.js

So the starting point is conf.js

conf.js generally contains onPrepare where you can keep environment details and reports generation options either customized or you use and package from npm packages. Also onPrepare has been one of the most useful parts of the config.js file as it allows to define my variables in one place and have access to them across the different spec.js files. See example

Globals: It is possible to set globals from the Protractor config file with the help of params property:

exports.config = {
// ...

params: {
    glob: 'test'
}

// ...
};

You Can use it in Spec as:

browser.executeScript(function (glob) {

// use passed variables on the page
console.log(glob);

}, browser.params.glob);

Sample taken from here

conf.js, onPrepare, globals are part of setup and pre-requistes to run test cases which are in specs some being optional.

After successful creation of those, specs are run which ever way you define it in conf.js running it in parallel/sequentially upon different browsers.

Example:

multiCapabilities: [
{
    shardTestFiles: true,
    maxInstances: 1,
    sequential: true,
    browserName: 'chrome',
    specs: ['specs/spec1.js','specs/spec2.js','specs/spec3.js']
},
{
    shardTestFiles: true,
    maxInstances: 1,
    sequential: true,
    browserName: 'chrome',
    specs: ['specs/spec4.js',
        'specs/spec5.js',
        'specs/spec6.js',
    ]
}

You can also define suites such as regression, sanity etc and run them individually.

protractor config.js --suite regression,sanity

For your question:

1) conf.js
2) globals & on Prepare
3)specs

I hope you are clear now.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Kishan Patel
  • 1,385
  • 3
  • 13
  • 24