undefined error in protractor on using a gettext() function and using it in other fileIs there a standard function to check for null, undefined, or blank variables in JavaScript?In Node.js, how do I “include” functions from my other files?How to getText on an input in protractorUsing angular functions ($q) in protractorConsole.log is executing before browser launches URLECONNREFUSED Webdriver errors in eclipse when running ProtractorAssertion not being called in Protractor codeProtractor - X is not a functionReturn a value from a promise within function to the test specProtractor's getText() method does not include text-transform done in a ::first-letter pseudoselector

Is it nonsense to say B -> [A -> B]?

The meaning of a て-form verb at the end of this sentence

How is CoreiX like Corei5, i7 is related to Haswell, Ivy Bridge?

Windows OS quantum vs. SQL OS Quantum

Is it bad writing or bad story telling if first person narrative contains more information than the narrator knows?

Has there been evidence of any other gods?

Two researchers want to work on the same extension to my paper. Who to help?

Peculiarities in low dimensions or low order or etc

How to make a language evolve quickly?

Is a vertical stabiliser needed for straight line flight in a glider?

Series that evaluates to different values upon changing order of summation

What food production methods would allow a metropolis like New York to become self sufficient

Improving Sati-Sampajañña (situative wisdom)

How to handle DM constantly stealing everything from sleeping characters?

How can I avoid subordinates and coworkers leaving work until the last minute, then having no time for revisions?

Why do protein solutions have to be alkalised?

How to evaluate sum with one million summands?

Why are parallelograms defined as quadrilaterals? What term would encompass polygons with greater than two parallel pairs?

Is this state of Earth possible, after humans left for a million years?

Is ‘despite that’ right?

Is there any evidence to support the claim that the United States was "suckered into WW1" by Zionists, made by Benjamin Freedman in his 1961 speech

Watching the game, having a puzzle

Are there non-military uses of 20%-enriched Uranium?

Was there a contingency plan in place if Little Boy failed to detonate?



undefined error in protractor on using a gettext() function and using it in other file


Is there a standard function to check for null, undefined, or blank variables in JavaScript?In Node.js, how do I “include” functions from my other files?How to getText on an input in protractorUsing angular functions ($q) in protractorConsole.log is executing before browser launches URLECONNREFUSED Webdriver errors in eclipse when running ProtractorAssertion not being called in Protractor codeProtractor - X is not a functionReturn a value from a promise within function to the test specProtractor's getText() method does not include text-transform done in a ::first-letter pseudoselector






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have written a utility function in InputBoxActions.js file for getting a text from the input field in protractor as as :



 this.getTextFromInputBox = function (element) 
if (typeof element !== 'undefined')
element.isDisplayed().then(function ()
element.isEnabled().then(function ()

element.getText().then(function(text)
return text;
)


);
);

;


However , on using the same function in the test spec file, i am getting the value of the text as undefined. Here i am calling the function as :



browserActions.goto(url);
var searchElement = findElements.byXpath("//input[@type='search']");
inputBoxActions.type(searchElement, 'angular');
var text = inputBoxActions.getTextFromInputBox(searchElement);
console.log(text);


Result i am getting is :



Started
undefined
(node:1412) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
.


1 spec, 0 failures
Finished in 6.082 seconds









share|improve this question




























    0















    I have written a utility function in InputBoxActions.js file for getting a text from the input field in protractor as as :



     this.getTextFromInputBox = function (element) 
    if (typeof element !== 'undefined')
    element.isDisplayed().then(function ()
    element.isEnabled().then(function ()

    element.getText().then(function(text)
    return text;
    )


    );
    );

    ;


    However , on using the same function in the test spec file, i am getting the value of the text as undefined. Here i am calling the function as :



    browserActions.goto(url);
    var searchElement = findElements.byXpath("//input[@type='search']");
    inputBoxActions.type(searchElement, 'angular');
    var text = inputBoxActions.getTextFromInputBox(searchElement);
    console.log(text);


    Result i am getting is :



    Started
    undefined
    (node:1412) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
    .


    1 spec, 0 failures
    Finished in 6.082 seconds









    share|improve this question
























      0












      0








      0








      I have written a utility function in InputBoxActions.js file for getting a text from the input field in protractor as as :



       this.getTextFromInputBox = function (element) 
      if (typeof element !== 'undefined')
      element.isDisplayed().then(function ()
      element.isEnabled().then(function ()

      element.getText().then(function(text)
      return text;
      )


      );
      );

      ;


      However , on using the same function in the test spec file, i am getting the value of the text as undefined. Here i am calling the function as :



      browserActions.goto(url);
      var searchElement = findElements.byXpath("//input[@type='search']");
      inputBoxActions.type(searchElement, 'angular');
      var text = inputBoxActions.getTextFromInputBox(searchElement);
      console.log(text);


      Result i am getting is :



      Started
      undefined
      (node:1412) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
      .


      1 spec, 0 failures
      Finished in 6.082 seconds









      share|improve this question














      I have written a utility function in InputBoxActions.js file for getting a text from the input field in protractor as as :



       this.getTextFromInputBox = function (element) 
      if (typeof element !== 'undefined')
      element.isDisplayed().then(function ()
      element.isEnabled().then(function ()

      element.getText().then(function(text)
      return text;
      )


      );
      );

      ;


      However , on using the same function in the test spec file, i am getting the value of the text as undefined. Here i am calling the function as :



      browserActions.goto(url);
      var searchElement = findElements.byXpath("//input[@type='search']");
      inputBoxActions.type(searchElement, 'angular');
      var text = inputBoxActions.getTextFromInputBox(searchElement);
      console.log(text);


      Result i am getting is :



      Started
      undefined
      (node:1412) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
      .


      1 spec, 0 failures
      Finished in 6.082 seconds






      javascript protractor angular-promise






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 10:05









      ashish chauhanashish chauhan

      327




      327






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Your innermost return statement is only returning the value to the function that calls it and then unused.



          -> element.getText().then(function(text)
          return text;
          );


          You need to return all the nested then's like so if you want to achieve this in this way.



          this.getTextFromInputBox = function (element) 
          if (typeof element !== 'undefined')
          return element.isDisplayed().then(function ()
          return element.isEnabled().then(function ()
          return element.getText().then(function (text)
          return text;
          )
          );
          );
          else
          throw new Error(`$element is undefined`);

          ;


          Imagine a line of guys who hand off some work to each other to complete. Your guy at the end is doing the work but not passing it back up the line to the boss where it is needed.






          share|improve this answer























          • Hi , Thanks a lot for the help. its working now:)

            – ashish chauhan
            Mar 23 at 16:21











          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%2f55312608%2fundefined-error-in-protractor-on-using-a-gettext-function-and-using-it-in-othe%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














          Your innermost return statement is only returning the value to the function that calls it and then unused.



          -> element.getText().then(function(text)
          return text;
          );


          You need to return all the nested then's like so if you want to achieve this in this way.



          this.getTextFromInputBox = function (element) 
          if (typeof element !== 'undefined')
          return element.isDisplayed().then(function ()
          return element.isEnabled().then(function ()
          return element.getText().then(function (text)
          return text;
          )
          );
          );
          else
          throw new Error(`$element is undefined`);

          ;


          Imagine a line of guys who hand off some work to each other to complete. Your guy at the end is doing the work but not passing it back up the line to the boss where it is needed.






          share|improve this answer























          • Hi , Thanks a lot for the help. its working now:)

            – ashish chauhan
            Mar 23 at 16:21















          0














          Your innermost return statement is only returning the value to the function that calls it and then unused.



          -> element.getText().then(function(text)
          return text;
          );


          You need to return all the nested then's like so if you want to achieve this in this way.



          this.getTextFromInputBox = function (element) 
          if (typeof element !== 'undefined')
          return element.isDisplayed().then(function ()
          return element.isEnabled().then(function ()
          return element.getText().then(function (text)
          return text;
          )
          );
          );
          else
          throw new Error(`$element is undefined`);

          ;


          Imagine a line of guys who hand off some work to each other to complete. Your guy at the end is doing the work but not passing it back up the line to the boss where it is needed.






          share|improve this answer























          • Hi , Thanks a lot for the help. its working now:)

            – ashish chauhan
            Mar 23 at 16:21













          0












          0








          0







          Your innermost return statement is only returning the value to the function that calls it and then unused.



          -> element.getText().then(function(text)
          return text;
          );


          You need to return all the nested then's like so if you want to achieve this in this way.



          this.getTextFromInputBox = function (element) 
          if (typeof element !== 'undefined')
          return element.isDisplayed().then(function ()
          return element.isEnabled().then(function ()
          return element.getText().then(function (text)
          return text;
          )
          );
          );
          else
          throw new Error(`$element is undefined`);

          ;


          Imagine a line of guys who hand off some work to each other to complete. Your guy at the end is doing the work but not passing it back up the line to the boss where it is needed.






          share|improve this answer













          Your innermost return statement is only returning the value to the function that calls it and then unused.



          -> element.getText().then(function(text)
          return text;
          );


          You need to return all the nested then's like so if you want to achieve this in this way.



          this.getTextFromInputBox = function (element) 
          if (typeof element !== 'undefined')
          return element.isDisplayed().then(function ()
          return element.isEnabled().then(function ()
          return element.getText().then(function (text)
          return text;
          )
          );
          );
          else
          throw new Error(`$element is undefined`);

          ;


          Imagine a line of guys who hand off some work to each other to complete. Your guy at the end is doing the work but not passing it back up the line to the boss where it is needed.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 23 at 10:34









          DublinDevDublinDev

          1,2342320




          1,2342320












          • Hi , Thanks a lot for the help. its working now:)

            – ashish chauhan
            Mar 23 at 16:21

















          • Hi , Thanks a lot for the help. its working now:)

            – ashish chauhan
            Mar 23 at 16:21
















          Hi , Thanks a lot for the help. its working now:)

          – ashish chauhan
          Mar 23 at 16:21





          Hi , Thanks a lot for the help. its working now:)

          – ashish chauhan
          Mar 23 at 16:21



















          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%2f55312608%2fundefined-error-in-protractor-on-using-a-gettext-function-and-using-it-in-othe%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

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현