Matthew Harwood Matthew Harwood - 1 year ago 155
AngularJS Question

Why must I use browser.sleep while writing protractor tests

My first run at E2E tests. I'm trying to digest someone else's protractor tests.

Problem: There are a lot of

and this seems fragile.

Goal: not to use

Question: What is a better approach to
? Something less fragile like a promise or something I dont know about lol?

var config = require('../../protractor.conf.js').config;
describe('this Homepage Body Tests', function(){

it("should open find a clinic page", function(){
// page loads :: want to fix this random wait interval
browser.ignoreSynchronization = true;

var string = 'clinic';
var main = '.search-large-text';
var link = element(by.cssContainingText('.submenu li a', string)); {
// page reloads :: want to fix this random wait interval
var title = element(by.cssContainingText(main, string));

Answer Source

Since there is an ignoreSynchronization turned on, you cannot use waitForAngular(), which would be a solution in case of an angular-site testing.

A better solution here would be to set a page load timeout:

browser.manage().timeouts().pageLoadTimeout(10000);  // 10 seconds

See also these relevant threads on explicit waits and timeouts:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download