how does the function calls be executed with protractor promise calls The Next CEO of Stack OverflowHow to manage a redirect request after a jQuery Ajax callHow to measure time taken by a function to executeHow to execute a JavaScript function when I have its name as a stringHow does JavaScript .prototype work?How does the “this” keyword work?What does the exclamation mark do before the function?How does data binding work in AngularJS?How do I return the response from an asynchronous call?How does Facebook disable the browser's integrated Developer Tools?Rejected promises in Protractor/WebDriverJS

Example of a Mathematician/Physicist whose Other Publications during their PhD eclipsed their PhD Thesis

How to start emacs in "nothing" mode (`fundamental-mode`)

Science fiction novels about a solar system spanning civilisation where people change their bodies at will

Can a caster that cast Polymorph on themselves stop concentrating at any point even if their Int is low?

How long to clear the 'suck zone' of a turbofan after start is initiated?

Why is there a PLL in CPU?

Anatomically Correct Strange Women In Ponds Distributing Swords

How do I get the green key off the shelf in the Dobby level of Lego Harry Potter 2?

What is the point of a new vote on May's deal when the indicative votes suggest she will not win?

Does the Brexit deal have to be agreed by both Houses?

Is there a good way to store credentials outside of a password manager?

Are there languages with no euphemisms?

Why does GHC infer a monomorphic type here, even with MonomorphismRestriction disabled?

Why do professional authors make "consistency" mistakes? And how to avoid them?

Does it take more energy to get to Venus or to Mars?

Implement the Thanos sorting algorithm

How to make a software documentation "officially" citable?

What can we do to stop prior company from asking us questions?

Removing read access from a file

Any way to transfer all permissions from one role to another?

Horror movie/show or scene where a horse creature opens its mouth really wide and devours a man in a stables

A pseudo-riley?

Only print output after finding pattern

How to count occurrences of text in a file?



how does the function calls be executed with protractor promise calls



The Next CEO of Stack OverflowHow to manage a redirect request after a jQuery Ajax callHow to measure time taken by a function to executeHow to execute a JavaScript function when I have its name as a stringHow does JavaScript .prototype work?How does the “this” keyword work?What does the exclamation mark do before the function?How does data binding work in AngularJS?How do I return the response from an asynchronous call?How does Facebook disable the browser's integrated Developer Tools?Rejected promises in Protractor/WebDriverJS










2















I am new to protractor, because i dont have much knowledge on Javascript its becoming difficult to predict the script execution flow. I have very basic question on the behavior of the protractor promises and flow of data between js files.



I have one commonTC.js which has describe(),it() block. In this 'it' block i call functions at runtime. Means, i have functions such as open(),click(),enter() written in another js file which gets called dynamically at run time as per function call data is read from excel.



In protractor most browser interaction returns promise, thus when i do logic of browser calls in click()/enter() these return promise, i wanted to get the details of browser calls in commonTC.js which is the calling file.



So i made function call as promise() in commonTC.js



 dynamicActions[enter()].then(()=>
console.log("Success Activity:")
).catch((err)=>
console.log("Error on Activity():")
throw err;
);


In ActivityAction.js(), the function definition is as below



this.dynamicActions.enter = function () 
var deferred = protractor.promise.defer();
element(by.id("username")).sendKeys("abc").then(
function success()
deferred.fulfill();
,
function error(reason)
deferred.reject(reason);
);
return deferred.promise;



My question is-
1. Because of this architecture all the function calls are required to be returned as promise.If i do not return the promise, does the browser promise result will i be knowing in commonTC.js?
2. Also by this architecture, is all the function calls are synchronous. Because all the functions are made to return as promise, so will those promise execute serially? i mean after 1st promise resolve, is it guaranteed 2nd promise will be executed/ or it might pick 5th also?
3. if it picks promise execution randomly then how can i achieve serial execution of promises?
4. If am required to remove promise architecture in commonTC.js then how to make sure each function open()/enter() returns failure/success?










share|improve this question


























    2















    I am new to protractor, because i dont have much knowledge on Javascript its becoming difficult to predict the script execution flow. I have very basic question on the behavior of the protractor promises and flow of data between js files.



    I have one commonTC.js which has describe(),it() block. In this 'it' block i call functions at runtime. Means, i have functions such as open(),click(),enter() written in another js file which gets called dynamically at run time as per function call data is read from excel.



    In protractor most browser interaction returns promise, thus when i do logic of browser calls in click()/enter() these return promise, i wanted to get the details of browser calls in commonTC.js which is the calling file.



    So i made function call as promise() in commonTC.js



     dynamicActions[enter()].then(()=>
    console.log("Success Activity:")
    ).catch((err)=>
    console.log("Error on Activity():")
    throw err;
    );


    In ActivityAction.js(), the function definition is as below



    this.dynamicActions.enter = function () 
    var deferred = protractor.promise.defer();
    element(by.id("username")).sendKeys("abc").then(
    function success()
    deferred.fulfill();
    ,
    function error(reason)
    deferred.reject(reason);
    );
    return deferred.promise;



    My question is-
    1. Because of this architecture all the function calls are required to be returned as promise.If i do not return the promise, does the browser promise result will i be knowing in commonTC.js?
    2. Also by this architecture, is all the function calls are synchronous. Because all the functions are made to return as promise, so will those promise execute serially? i mean after 1st promise resolve, is it guaranteed 2nd promise will be executed/ or it might pick 5th also?
    3. if it picks promise execution randomly then how can i achieve serial execution of promises?
    4. If am required to remove promise architecture in commonTC.js then how to make sure each function open()/enter() returns failure/success?










    share|improve this question
























      2












      2








      2








      I am new to protractor, because i dont have much knowledge on Javascript its becoming difficult to predict the script execution flow. I have very basic question on the behavior of the protractor promises and flow of data between js files.



      I have one commonTC.js which has describe(),it() block. In this 'it' block i call functions at runtime. Means, i have functions such as open(),click(),enter() written in another js file which gets called dynamically at run time as per function call data is read from excel.



      In protractor most browser interaction returns promise, thus when i do logic of browser calls in click()/enter() these return promise, i wanted to get the details of browser calls in commonTC.js which is the calling file.



      So i made function call as promise() in commonTC.js



       dynamicActions[enter()].then(()=>
      console.log("Success Activity:")
      ).catch((err)=>
      console.log("Error on Activity():")
      throw err;
      );


      In ActivityAction.js(), the function definition is as below



      this.dynamicActions.enter = function () 
      var deferred = protractor.promise.defer();
      element(by.id("username")).sendKeys("abc").then(
      function success()
      deferred.fulfill();
      ,
      function error(reason)
      deferred.reject(reason);
      );
      return deferred.promise;



      My question is-
      1. Because of this architecture all the function calls are required to be returned as promise.If i do not return the promise, does the browser promise result will i be knowing in commonTC.js?
      2. Also by this architecture, is all the function calls are synchronous. Because all the functions are made to return as promise, so will those promise execute serially? i mean after 1st promise resolve, is it guaranteed 2nd promise will be executed/ or it might pick 5th also?
      3. if it picks promise execution randomly then how can i achieve serial execution of promises?
      4. If am required to remove promise architecture in commonTC.js then how to make sure each function open()/enter() returns failure/success?










      share|improve this question














      I am new to protractor, because i dont have much knowledge on Javascript its becoming difficult to predict the script execution flow. I have very basic question on the behavior of the protractor promises and flow of data between js files.



      I have one commonTC.js which has describe(),it() block. In this 'it' block i call functions at runtime. Means, i have functions such as open(),click(),enter() written in another js file which gets called dynamically at run time as per function call data is read from excel.



      In protractor most browser interaction returns promise, thus when i do logic of browser calls in click()/enter() these return promise, i wanted to get the details of browser calls in commonTC.js which is the calling file.



      So i made function call as promise() in commonTC.js



       dynamicActions[enter()].then(()=>
      console.log("Success Activity:")
      ).catch((err)=>
      console.log("Error on Activity():")
      throw err;
      );


      In ActivityAction.js(), the function definition is as below



      this.dynamicActions.enter = function () 
      var deferred = protractor.promise.defer();
      element(by.id("username")).sendKeys("abc").then(
      function success()
      deferred.fulfill();
      ,
      function error(reason)
      deferred.reject(reason);
      );
      return deferred.promise;



      My question is-
      1. Because of this architecture all the function calls are required to be returned as promise.If i do not return the promise, does the browser promise result will i be knowing in commonTC.js?
      2. Also by this architecture, is all the function calls are synchronous. Because all the functions are made to return as promise, so will those promise execute serially? i mean after 1st promise resolve, is it guaranteed 2nd promise will be executed/ or it might pick 5th also?
      3. if it picks promise execution randomly then how can i achieve serial execution of promises?
      4. If am required to remove promise architecture in commonTC.js then how to make sure each function open()/enter() returns failure/success?







      javascript protractor






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 8 at 12:41









      radha janagoudaradha janagouda

      254




      254






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Protractor has a build-in promise manager named Control Flow which keep the promises in a list and guarantee promises in the list executed serially as the order as they appeared in your script.



          it('promise execute order', ()=>
          browser.get('...') // promise 1
          element(by.xxx(...)).sendKeys(); // promise 2
          element(by.xxx(...)).sendKeys()
          .then(()=> yyyy.then()....) // nested `then()`
          .then()
          .catch() // promise 3, no matter how many `then()` followed
          // and nested. They are treated as single promise

          element(by.xxx(...)).click(); // promise 4
          )

          // There are 4 lines in above `it`, every protractor api return a promise
          // thus there will be a list includes 4 promises:
          // [promise 1, promise 2, promise 3, promise 4]
          // Control Flow makes sure promise in list executed one by one.





          share|improve this answer























          • Thanks a lot yong. This relieved from big stress. Thanks a ton!! Is there any supporting document from protractor team on this, apologies, case if things turn back to me, want to keep some record.

            – radha janagouda
            Mar 9 at 18:53











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55063459%2fhow-does-the-function-calls-be-executed-with-protractor-promise-calls%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Protractor has a build-in promise manager named Control Flow which keep the promises in a list and guarantee promises in the list executed serially as the order as they appeared in your script.



          it('promise execute order', ()=>
          browser.get('...') // promise 1
          element(by.xxx(...)).sendKeys(); // promise 2
          element(by.xxx(...)).sendKeys()
          .then(()=> yyyy.then()....) // nested `then()`
          .then()
          .catch() // promise 3, no matter how many `then()` followed
          // and nested. They are treated as single promise

          element(by.xxx(...)).click(); // promise 4
          )

          // There are 4 lines in above `it`, every protractor api return a promise
          // thus there will be a list includes 4 promises:
          // [promise 1, promise 2, promise 3, promise 4]
          // Control Flow makes sure promise in list executed one by one.





          share|improve this answer























          • Thanks a lot yong. This relieved from big stress. Thanks a ton!! Is there any supporting document from protractor team on this, apologies, case if things turn back to me, want to keep some record.

            – radha janagouda
            Mar 9 at 18:53















          0














          Protractor has a build-in promise manager named Control Flow which keep the promises in a list and guarantee promises in the list executed serially as the order as they appeared in your script.



          it('promise execute order', ()=>
          browser.get('...') // promise 1
          element(by.xxx(...)).sendKeys(); // promise 2
          element(by.xxx(...)).sendKeys()
          .then(()=> yyyy.then()....) // nested `then()`
          .then()
          .catch() // promise 3, no matter how many `then()` followed
          // and nested. They are treated as single promise

          element(by.xxx(...)).click(); // promise 4
          )

          // There are 4 lines in above `it`, every protractor api return a promise
          // thus there will be a list includes 4 promises:
          // [promise 1, promise 2, promise 3, promise 4]
          // Control Flow makes sure promise in list executed one by one.





          share|improve this answer























          • Thanks a lot yong. This relieved from big stress. Thanks a ton!! Is there any supporting document from protractor team on this, apologies, case if things turn back to me, want to keep some record.

            – radha janagouda
            Mar 9 at 18:53













          0












          0








          0







          Protractor has a build-in promise manager named Control Flow which keep the promises in a list and guarantee promises in the list executed serially as the order as they appeared in your script.



          it('promise execute order', ()=>
          browser.get('...') // promise 1
          element(by.xxx(...)).sendKeys(); // promise 2
          element(by.xxx(...)).sendKeys()
          .then(()=> yyyy.then()....) // nested `then()`
          .then()
          .catch() // promise 3, no matter how many `then()` followed
          // and nested. They are treated as single promise

          element(by.xxx(...)).click(); // promise 4
          )

          // There are 4 lines in above `it`, every protractor api return a promise
          // thus there will be a list includes 4 promises:
          // [promise 1, promise 2, promise 3, promise 4]
          // Control Flow makes sure promise in list executed one by one.





          share|improve this answer













          Protractor has a build-in promise manager named Control Flow which keep the promises in a list and guarantee promises in the list executed serially as the order as they appeared in your script.



          it('promise execute order', ()=>
          browser.get('...') // promise 1
          element(by.xxx(...)).sendKeys(); // promise 2
          element(by.xxx(...)).sendKeys()
          .then(()=> yyyy.then()....) // nested `then()`
          .then()
          .catch() // promise 3, no matter how many `then()` followed
          // and nested. They are treated as single promise

          element(by.xxx(...)).click(); // promise 4
          )

          // There are 4 lines in above `it`, every protractor api return a promise
          // thus there will be a list includes 4 promises:
          // [promise 1, promise 2, promise 3, promise 4]
          // Control Flow makes sure promise in list executed one by one.






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 8 at 13:35









          yongyong

          7,1611412




          7,1611412












          • Thanks a lot yong. This relieved from big stress. Thanks a ton!! Is there any supporting document from protractor team on this, apologies, case if things turn back to me, want to keep some record.

            – radha janagouda
            Mar 9 at 18:53

















          • Thanks a lot yong. This relieved from big stress. Thanks a ton!! Is there any supporting document from protractor team on this, apologies, case if things turn back to me, want to keep some record.

            – radha janagouda
            Mar 9 at 18:53
















          Thanks a lot yong. This relieved from big stress. Thanks a ton!! Is there any supporting document from protractor team on this, apologies, case if things turn back to me, want to keep some record.

          – radha janagouda
          Mar 9 at 18:53





          Thanks a lot yong. This relieved from big stress. Thanks a ton!! Is there any supporting document from protractor team on this, apologies, case if things turn back to me, want to keep some record.

          – radha janagouda
          Mar 9 at 18:53



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55063459%2fhow-does-the-function-calls-be-executed-with-protractor-promise-calls%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to get text form Clipboard with JavaScript in Firefox 56?How to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?Get the current URL with JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?

          Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

          List of MPs elected to the English parliament in 1640 (April) Contents List of constituencies and members See also Notes References Navigation menueNational Archives – The Glynde Place ArchivesCobbett's Parliamentary history of England, from the Norman Conquest in 1066 to the year 1803'Aldermen in Parliament', The Aldermen of the City of London: Temp. Henry III – 1912onepage&q&f&#61, false 229