Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 6ae6261

Browse files
committed
refactor(waitForAngular): improve error messages when timeouts occur
1 parent 0bcaedb commit 6ae6261

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

lib/protractor.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,24 @@ Protractor.prototype.waitForAngular = function() {
411411
'sync with the page: ' + JSON.stringify(browserErr);
412412
}
413413
}).then(null, function(err) {
414-
if (!/asynchronous script timeout/.test(err.message)) {
414+
var timeout;
415+
if (/asynchronous script timeout/.test(err.message)) {
416+
// Timeout on Chrome
417+
timeout = /[\d\.]*\ seconds/.exec(err.message);
418+
} else if (/Timed out waiting for async script/.test(err.message)) {
419+
// Timeout on Firefox
420+
timeout = /[\d\.]*ms/.exec(err.message);
421+
} else if (/Timed out waiting for an asynchronous script/.test(err.message)) {
422+
// Timeout on Safari
423+
timeout = /[\d\.]*\ ms/.exec(err.message);
424+
}
425+
if (timeout) {
426+
throw 'Timed out waiting for Protractor to synchronize with ' +
427+
'the page after ' + timeout + '. Please see ' +
428+
'https://github.com/angular/protractor/blob/master/docs/faq.md';
429+
} else {
415430
throw err;
416431
}
417-
var timeout = /[\d\.]*\ seconds/.exec(err.message);
418-
throw 'Timed out waiting for Protractor to synchronize with ' +
419-
'the page after ' + timeout;
420432
});
421433
};
422434

0 commit comments

Comments
 (0)