0

I could see the common tests are excluded in a suite configuration of protractor. Below is my config.js and there are two scenarios configured in suites.

I'm expecting the test to complete the scenario1 successfully and then Login again as part of scenario2. But, I could see the test ignores 'Login.js', 'CustomerSelection.js', 'Create.js' of Scenario2 and directly proceeds with 'ProductSelection.js'.

Any idea why is that so ? Am I missing anything in conf.js to work the way the scenarios configured ?

Config.js:

exports.config = {
      seleniumAddress: 'http://localhost:4444/wd/hub',
      capabilities: {
      'browserName': 'chrome'
    },
    framework: 'jasmine' ,
    showColors: true,  
suites : {
  scenario1: [
        'Login.js',
        'CustomerSelection.js',
        'Create.js',
        'View.js',
    ],
  scenario2: [
        'Login.js',
        'CustomerSelection.js',
        'Create.js',
        'ProductSelection.js',
    ]
},

jasmineNodeOpts: {
    isVerbose: true,
    showColors: true,
    print: function () {
    },
    includeStackTrace: true,
    defaultTimeoutInterval: 700000
},

onPrepare: function() {
    browser.manage().window().maximize();
    browser.manage().timeouts().implicitlyWait(5000);
    }
};

Below are the versions I'm using:

protractor: Version 5.4.0

Jasmine: Version 3.2.0

Node: v8.11.1

NPM: Version 5.6.0

Ashish
  • 161
  • 1
  • 2
  • 10

1 Answers1

0

If this tests are something that you run always before all. You can place them like this into View.js and ProductSelection.js as part of beforeAll, I'm placing login beforeAll (loginPage is page where my functions are placed, Login() is function in loginPage that logins in application if you send correct username and password to it) like this:

beforeAll(function() {
    loginPage.Login(username, password);        
});
Sanja Paskova
  • 1,110
  • 8
  • 15
  • I did try adding beforeAll in ProductSelection.js Sanja. But, still I don't see the browser to close again and login as I expect. It just ignores the login part and moves ahead with tests written in ProductSelection.js. Am I missing anything else ? – Ashish Aug 17 '18 at 13:17
  • Any other way to achieve this or any changes to be made in what I have done ? – Ashish Aug 20 '18 at 09:05
  • Use beforeEach instead of beforeAll – Sanja Paskova Aug 20 '18 at 21:55