javascript - how to return object from protractor -
i have written following code return text table.
now, want thing in here: dnassgn
page name, after calling function return value coming blank. please suggest me wrong.
fetch_text_from_cell_in_table: function(col_val){ var name_var=""; var km = 0; var dm = 0; pointer1 = element.all(by.repeater('row in renderedrows')).then(function(posts) { (ni = 0; ni < posts.length; ni++) name_var= posts[ni].element(by.classname(col_val)).gettext().then(function(name){ //console.log(valdation_value); console.log(col_val); console.log(name); var name_var = name.trim(); return name; }); }); return name_var; }, var dn_num=dnassgn.fetch_text_from_cell_in_table('colt0'); expect(dn_num).tobe('not found');
first of all, not returning function.
besides, understand, need filter table , text values of cell in specific column (cell having specific class name, e.g. colt0
). use map()
:
function fetch_text_from_cell_in_table (col_val) { return element.all(by.repeater('row in renderedrows')).map(function(post) { return post.element(by.classname(col_val)).gettext(); }); });
usage:
var dn_num = dnassgn.fetch_text_from_cell_in_table('colt0'); expect(dn_num).tobe(['not found']);
Comments
Post a Comment