This repository was archived by the owner on Jul 29, 2024. It is now read-only.
File tree 2 files changed +20
-10
lines changed
2 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -284,7 +284,7 @@ clientSideScripts.findSelectedOption = function() {
284
284
*
285
285
* arguments none.
286
286
*/
287
- clientSideScripts . testForAngular = function ( ) {
287
+ clientSideScripts . testForAngular = function ( ) {
288
288
var attempts = arguments [ 0 ] ;
289
289
var callback = arguments [ arguments . length - 1 ] ;
290
290
var check = function ( n ) {
@@ -298,3 +298,18 @@ clientSideScripts.findSelectedOption = function() {
298
298
} ;
299
299
check ( attempts ) ;
300
300
} ;
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
+ } ;
Original file line number Diff line number Diff line change @@ -174,19 +174,14 @@ Protractor.prototype.wrapWebElement = function(element) {
174
174
*
175
175
* @return {!webdriver.promise.Promise } A promise that will resolve to the
176
176
* 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
179
179
* will be returned as a WebElement.
180
180
*/
181
181
element . evaluate = function ( expression ) {
182
- // TODO: put into clientSideScripts
183
182
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 ) ;
190
185
} ;
191
186
192
187
return element ;
You can’t perform that action at this time.
0 commit comments