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

Commit

Permalink
feat(elementFinder): keep a reference to the original locator
Browse files Browse the repository at this point in the history
  • Loading branch information
elgalu authored and juliemr committed May 17, 2014
1 parent 98f4ba5 commit b93bf18
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/protractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ var buildElementHelper = function(ptor, opt_usingChain) {
return using().isElementPresent(locator);
};

/**
* Returns the originally specified locator.
*
* @return {webdriver.Locator} The element locator.
*/
elementFinder.locator = function() {
return locator;
};

/**
* Calls to element may be chained to find elements within a parent.
*
Expand Down
7 changes: 7 additions & 0 deletions spec/basic/findelements_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,13 @@ describe('global element function', function() {
expect(element(by.binding('greet')).isPresent()).toBe(true);
expect(element(by.binding('nopenopenope')).isPresent()).toBe(false);
});

it('should keep a reference to the original locator', function() {
var byCss = by.css('body');
var byBinding = by.binding('greet');
expect(element(byCss).locator()).toEqual(byCss);
expect(element(byBinding).locator()).toEqual(byBinding);
});
});

describe('evaluating statements', function() {
Expand Down

0 comments on commit b93bf18

Please sign in to comment.