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

Commit f56357a

Browse files
committed
Moving the 'evaluate' script into clientSideScripts.
1 parent 4efe543 commit f56357a

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

Diff for: lib/clientsidescripts.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ clientSideScripts.findSelectedOption = function() {
284284
*
285285
* arguments none.
286286
*/
287-
clientSideScripts.testForAngular = function() {
287+
clientSideScripts.testForAngular = function() {
288288
var attempts = arguments[0];
289289
var callback = arguments[arguments.length - 1];
290290
var check = function(n) {
@@ -298,3 +298,18 @@ clientSideScripts.findSelectedOption = function() {
298298
};
299299
check(attempts);
300300
};
301+
302+
/**
303+
* Evalute an Angular expression in the context of a given element.
304+
*
305+
* arguments[0] {Element} The element in whose scope to evaluate.
306+
* arguments[1] {string} The expression to evaluate.
307+
*
308+
* @return {?Object} The result of the evaluation.
309+
*/
310+
clientSideScripts.evaluate = function() {
311+
var element = arguments[0];
312+
var expression = arguments[1];
313+
314+
return angular.element(element).scope().$eval(expression);
315+
};

Diff for: lib/protractor.js

+4-9
Original file line numberDiff line numberDiff line change
@@ -174,19 +174,14 @@ Protractor.prototype.wrapWebElement = function(element) {
174174
*
175175
* @return {!webdriver.promise.Promise} A promise that will resolve to the
176176
* evaluated expression. The result will be resolved as in
177-
* webdriver.WebDriver.executeScript. In summary - primitives will be
178-
* resolved as is, functions will be converted to string, and elements
177+
* {@link webdriver.WebDriver.executeScript}. In summary - primitives will
178+
* be resolved as is, functions will be converted to string, and elements
179179
* will be returned as a WebElement.
180180
*/
181181
element.evaluate = function(expression) {
182-
// TODO: put into clientSideScripts
183182
thisPtor.waitForAngular();
184-
return element.getDriver().executeScript(function() {
185-
var element = arguments[0];
186-
var expression = arguments[1];
187-
188-
return angular.element(element).scope().$eval(expression)
189-
}, element, expression);
183+
return element.getDriver().executeScript(clientSideScripts.evaluate,
184+
element, expression);
190185
};
191186

192187
return element;

0 commit comments

Comments
 (0)