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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -