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

Commit b6f1a63

Browse files
luishvzcnishina
authored andcommitted
fix(protractor): Shows locator used when a timeout occurs
1 parent de4b33e commit b6f1a63

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/element.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ ElementArrayFinder.prototype.all = function(locator) {
130130
var getWebElements = function() {
131131
if (self.getWebElements === null) {
132132
// This is the first time we are looking for an element
133-
return ptor.waitForAngular().then(function() {
133+
return ptor.waitForAngular('Locator: ' + locator).then(function() {
134134
if (locator.findElementsOverride) {
135135
return locator.findElementsOverride(ptor.driver, null, ptor.rootEl);
136136
} else {

lib/protractor.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,11 @@ Protractor.prototype.waitForAngular = function(opt_description) {
401401
}
402402
if (timeout) {
403403
var errMsg = 'Timed out waiting for Protractor to synchronize with ' +
404-
'the page after ' + timeout + '. Please see ' +
405-
'https://github.com/angular/protractor/blob/master/docs/faq.md';
404+
'the page after ' + timeout + '. Please see ' +
405+
'https://github.com/angular/protractor/blob/master/docs/faq.md';
406+
if(description.startsWith(' - Locator: ')){
407+
errMsg += '\n' + description
408+
};
406409
var pendingTimeoutsPromise;
407410
if (self.trackOutstandingTimeouts_) {
408411
pendingTimeoutsPromise = self.executeScript_(
@@ -426,14 +429,14 @@ Protractor.prototype.waitForAngular = function(opt_description) {
426429
var key, pendingTasks = [];
427430
for (key in pendingTimeouts) {
428431
if (pendingTimeouts.hasOwnProperty(key)) {
429-
pendingTasks.push('- $timeout: ' + pendingTimeouts[key]);
432+
pendingTasks.push(' - $timeout: ' + pendingTimeouts[key]);
430433
}
431434
}
432435
for (key in pendingHttps) {
433-
pendingTasks.push('- $http: ' + pendingHttps[key].url);
436+
pendingTasks.push(' - $http: ' + pendingHttps[key].url);
434437
}
435438
if (pendingTasks.length) {
436-
errMsg += '. The following tasks were pending:\n';
439+
errMsg += '. \nThe following tasks were pending:\n';
437440
errMsg += pendingTasks.join('\n');
438441
}
439442
throw errMsg;

0 commit comments

Comments
 (0)