Saturday, 15 January 2011

javascript - asynchronous execution in protractor end to end tests -


I have written a function, which is returning a value, in my main I am calling a function like this: / P>

  var fn_return_val = lesson.select_lesson (lesson1_text); Console.log ("The returned value is:" + fn_return_val);  

and my function is like implementation (other file.js):

  module.exports = {select_lesson: function select_lesson (lesson_name) {console. Log ('\ N ***************************************************************************** ******** The desired option, position; var repeter = element.all (by.repeater (item in the item)); Repeter.then (function (items) {items.forEach (function (icon) {console .log ('\ n ********************************************************************************************************* {if (desiredOption) {var el = desired optoption.all -Click = 'Launch activity ()'] ')); var L_progress = desired_action.all (CSS (' PNA-progress')); var abc = el.getAttribut E ('value') then (function (txt) {status = txt} return status}) el_progress.getAttribute ('style'). Then (function (progress) {console.log ('\ n **** * ****************************************************************************************************************************); el.click 

The problem function is returning the "undefined" value, and print statement console.log ("the value returned is:" + fn_return_val); function implementation

Can I help solve this?

This is all about promise and protector.

You must log in the results to resolve the promise and :

  lesson .select_lesson (lesson1_text) ) .then (function (fn_return_val) {console.log ("returned value is:" + fn_return_val);});  

And you also need to go back with a function:

  function select_lesson (lesson_name) {... // return here repeter.then (Function (item) {...}). Then (function click operation () {...}); }); }  

No comments:

Post a Comment