This repository was archived by the owner on Jul 29, 2024. It is now read-only.
File tree 3 files changed +18
-9
lines changed
3 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -229,14 +229,16 @@ ElementArrayFinder.prototype.filter = function(filterFn) {
229
229
* expect(list.get(0).getText()).toBe('First');
230
230
* expect(list.get(1).getText()).toBe('Second');
231
231
*
232
- * @param {number } index Element index.
232
+ * @param {number|webdriver.promise.Promise } index Element index.
233
233
* @return {ElementFinder } finder representing element at the given index.
234
234
*/
235
235
ElementArrayFinder . prototype . get = function ( index ) {
236
236
var self = this ;
237
237
var getWebElements = function ( ) {
238
- return self . getWebElements ( ) . then ( function ( parentWebElements ) {
239
- var i = index ;
238
+ return webdriver . promise . all ( [ index , self . getWebElements ( ) ] ) . then ( function ( results ) {
239
+ var i = results [ 0 ] ;
240
+ var parentWebElements = results [ 1 ] ;
241
+
240
242
if ( i < 0 ) {
241
243
// wrap negative indices
242
244
i = parentWebElements . length + i ;
Original file line number Diff line number Diff line change @@ -119,9 +119,9 @@ executor.addCommandlineTest('node lib/cli.js spec/errorTest/slowHttpAndTimeoutCo
119
119
. expectExitCode ( 1 )
120
120
. expectErrors ( [
121
121
{ message : 'The following tasks were pending[\\s\\S]*\\$http: \/slowcall' } ,
122
- { message : 'The following tasks were pending[\\s\\S]*' +
123
- '\\$timeout: function \\(\\) {[\\s\\S]*' +
124
- '\\$scope\\.slowAngularTimeoutStatus = \'done\';[\\s\\S]' +
122
+ { message : 'The following tasks were pending[\\s\\S]*' +
123
+ '\\$timeout: function \\(\\) {[\\s\\S]*' +
124
+ '\\$scope\\.slowAngularTimeoutStatus = \'done\';[\\s\\S]' +
125
125
'*}' }
126
126
] ) ;
127
127
Original file line number Diff line number Diff line change 1
- var util = require ( 'util' ) ;
2
-
3
1
describe ( 'ElementFinder' , function ( ) {
4
2
beforeEach ( function ( ) {
5
3
// Clear everything between each test.
@@ -346,7 +344,7 @@ describe('ElementArrayFinder', function() {
346
344
expect ( element . all ( by . binding ( 'doesnotexist' ) ) . count ( ) ) . toEqual ( 0 ) ;
347
345
} ) ;
348
346
349
- it ( 'should return not present when an element disappears within an array' ,
347
+ it ( 'should return not present when an element disappears within an array' ,
350
348
function ( ) {
351
349
browser . get ( 'index.html#/form' ) ;
352
350
element . all ( by . model ( 'color' ) ) . then ( function ( elements ) {
@@ -367,6 +365,15 @@ describe('ElementArrayFinder', function() {
367
365
expect ( colorList . get ( 2 ) . getAttribute ( 'value' ) ) . toEqual ( 'red' ) ;
368
366
} ) ;
369
367
368
+ it ( 'should get an element from an array by promise index' , function ( ) {
369
+ var colorList = element . all ( by . model ( 'color' ) ) ;
370
+ var index = protractor . promise . fulfilled ( 1 ) ;
371
+
372
+ browser . get ( 'index.html#/form' ) ;
373
+
374
+ expect ( colorList . get ( index ) . getAttribute ( 'value' ) ) . toEqual ( 'green' ) ;
375
+ } ) ;
376
+
370
377
it ( 'should get an element from an array using negative indices' , function ( ) {
371
378
var colorList = element . all ( by . model ( 'color' ) ) ;
372
379
You can’t perform that action at this time.
0 commit comments