javascript - Protractor - Wait for multiple elements -


i trying wait multiple elements on page, don't know how many there there @ least one. understand waiting single element using following, works fine.

var ec = protractor.expectedconditions;     browser.wait(ec.presenceof(element(by.css("h3[title='test form']"))), 10000);     expect(element(by.css("h3[title='test form']")).ispresent()).tobetruthy(); 

i wanted change wait multiple elements , tried below (adding .all element).

var ec = protractor.expectedconditions;     browser.wait(ec.presenceof(element.all(by.css("h3[title='test form']"))), 10000);     expect(element.all(by.css("h3[title='test form']")).ispresent()).tobetruthy(); 

unfortunately when try

cannot read property 'bind' of undefined 

any on appreciated.

p.s. newbie protracor , quirks.

presenceof expects single element (elementfinder) passed in.

you need custom expected condition wait for. if understand correctly, need wait until n elements present. here how can it:

function waitforcount (elementarrayfinder, expectedcount) {     return function () {         return elementarrayfinder.count().then(function (actualcount) {             return expectedcount === actualcount;  // or <= instead of ===, depending on use case         });     }; }; 

usage:

var forms = element.all(by.css("h3[title='test form']")); browser.wait(waitforcount(forms, 5), 10000); 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -