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

Commit

Permalink
fix(locators): Missing information in warning/error messages
Browse files Browse the repository at this point in the history
Webdriver's built-in locators (such as `by.css()`) appeared as
'undefined' in protractor's messages.

For instance, if a locator matched multiple elements, protractor
would print the following message: 'warning: more than one element
found for locator undefined- you may need to be more specific'.
  • Loading branch information
urish authored and juliemr committed Jun 9, 2014
1 parent 13373f5 commit 59af936
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/protractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,15 +568,16 @@ var buildElementHelper = function(ptor) {
this.locator_, this.parentElementFinder_).getWebElements();

var id = webElementsPromise.then(function(arr) {
var locatorMessage = (self.locator_.message || self.locator_.toString());
if (!arr.length) {
throw new Error('No element found using locator: ' + self.locator_.message);
throw new Error('No element found using locator: ' + locatorMessage);
}
var index = self.opt_index_;
if (index == null) {
// index null means we make sure there is only one element
if (arr.length > 1) {
console.log('warning: more than one element found for locator ' +
self.locator_.message + '- you may need to be more specific');
locatorMessage + ' - you may need to be more specific');
}
index = 0;
} else if (index === -1) {
Expand Down

0 comments on commit 59af936

Please sign in to comment.