Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
62
rated 0 times [  68] [ 6]  / answers: 1 / hits: 41627  / 9 Years ago, wed, june 17, 2015, 12:00:00

I have some tests written using protractor for angular.js app. I am using Page Objects design pattern and there i have some methods that navigate to other pages by clicking on links and buttons. and soon after that i am calling browser.waitForAngular().



Page Object



module.exports = function () {
this.companyNameLink = element(by.id('viewCompany'));
this.newMeetingButton = element(by.id('newMeetingButton'));

this.createNewGeneralMeeting = function () {
this.newMeetingButton.click();
browser.waitForAngular();
};

this.goToCompanyPage = function () {
this.companyNameLink.click();
browser.waitForAngular();
};
};


And in some spec file i use this page object like this..



var DashboardPage = require('../dashboardPageObject.js');
dashboardPage = new DashboardPage();

...

dashboardPage.goToCompanyPage();


But the problem is sometimes i get the angular could not be found on the window error and my tests fail. Most of the time the tests run. This issue is random. My question is that should i remove the browser.waitForAngular() from the page object method and call it after i make the method call like this...



Modified Page Object



...
this.goToCompanyPage = function () {
this.companyNameLink.click();
};
...


Spec File



dashboardPage.goToCompanyPage();
browser.waitForAngular();


Is calling browser.waitForAngular() causing the issue? Where should i call waitForAngular is there any best practice on how to use this?


More From » angularjs

 Answers
6

From protractor's documentation:




Instruct webdriver to wait until Angular has finished rendering and has no outstanding $http or $timeout calls before continuing. Note that Protractor automatically applies this command before every WebDriver action.




You shouldn't be calling this at all and I cannot think of a valid case where you should.


[#66180] Monday, June 15, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alorac

Total Points: 262
Total Questions: 82
Total Answers: 97

Location: Libya
Member since Mon, Dec 7, 2020
4 Years ago
alorac questions
Sat, Oct 10, 20, 00:00, 4 Years ago
Tue, Sep 22, 20, 00:00, 4 Years ago
Wed, Jul 1, 20, 00:00, 4 Years ago
Wed, Jun 3, 20, 00:00, 4 Years ago
Sun, May 17, 20, 00:00, 4 Years ago
;