lundi 23 mars 2015

Protractor:count() doesn't work outside of expect()

I tried to write a function to wait for the number of some kinds of elements to be a specific number, my code is:



waitelementnum= function (num) {
var elmnum=element.all(by.xpath("//div[@class='notification-content']")).count();
browser.wait(function () {
return (elmnum>num);
}, 10000);
};


but it always timeout. then I try to print the result of count like:



console.log(element.all(by.xpath("//div[@class='notification-content']")).count());


nothing was printed out;


but when I tried:



expect(element.all(by.xpath("//div[@class='notification-content']")).count()).toEqual(2);


it reported:



expecting 1 to be 2.


So world anybody kindly tell me what's wrong with my function?


Aucun commentaire:

Enregistrer un commentaire