1

Page Object Model File:

var loginPage = function() {
    console.log('Constructor~!');
};

loginPage.prototype = {
    constructor: loginPage,

    login: function () {
        console.log('now I doing something');
        browser.sleep(10000);
    },

    searchForElements: function () {
        console.log('action that is after I login');
        browser.sleep(20000);
    },

    addAnotherUser: function () {
        console.log('now I doing something way into the future');
    },

};

module.exports = loginPage;

Protractor Test File:

 var loginPage = require("../pages/test.page.js");

describe('Creating new account', function(){

   it('account will be created',function(){

    loginPage = new loginPage();
    loginPage.login();
    console.log('On the page');
    loginPage.searchForElements();
    loginPage.addAnotherUser();

  });

});

When I run this using protractor the console immediately prints out:
Constructor~!
now I doing something
On the page
action that is after I login
now I doing something way into the future

I would have thought that it wouldn't echo out the 'On the page' until after the browser has waited 10 seconds.

How can I sync up the browser and the javascript so that the searchForElements function doesn't run until the browser has completed the login function?

ClickThisNick
  • 5,110
  • 9
  • 44
  • 69

0 Answers0