angularjs - How to get the text of all elements in protractor -
angularjs - How to get the text of all elements in protractor -
i want fetch li texts of suggestions after entering in google search bar "webdriver". have wrote code this:
this.getelements = function(){ element.all(by.css('ul.sbsb_b')).then(function(text){ for(var i=0; < text.length;i++) { console.log(text[i].gettext()); } }); }; on execution m getting like:
{ ptor_: { controlflow: [function], schedule: [function], getsession: [function], getcapabilities: [function], quit: [function], instead of text values of suggestions.
there set of javascript array-like functions in protractor allows filter() or map() result of async promise. illustration if original "element.all(by.css('something'))" homecoming list of elementfinders, map() allows transform array of gettext()s, in resolved state array of strings. can utilize want.
element.all(by.css('something')).map(function(elm) { homecoming elm.gettext(); }).then(function(texts) { texts.foreach(...); }); angularjs protractor
Comments
Post a Comment