selenium Promise while expecting a string to be returned2019 Community Moderator ElectionWhy does ++[[]][+[]]+[+[]] return the string “10”?Not able to add Recipient and not able to printSelenium Web Driver Eclipse: Passing the username and password from json file or xml fileSelenium.Unable to enter username and password for a websiteLogging in using Javascript and Selenium Webdriver (Chrome)Node Js printing before executionSelenium Java Appium Http proxySelenium example using Node.js from MDN not working?How to make the selenium webdriver script to wait for backend api request to return a response?

What was the Kree's motivation in Captain Marvel?

How strictly should I take "Candidates must be local"?

PTIJ: Should I kill my computer after installing software?

How does one describe somebody who is bi-racial?

Do I really need to have a scientific explanation for my premise?

How many characters using PHB rules does it take to be able to have access to any PHB spell at the start of an adventuring day?

What are some noteworthy "mic-drop" moments in math?

Declaring and defining template, and specialising them

Is it necessary to separate DC power cables and data cables?

How to detect if C code (which needs 'extern C') is compiled in C++

Error during using callback start_page_number in lualatex

Why does Captain Marvel assume the people on this planet know this?

How to secure an aircraft at a transient parking space?

Latex does not go to next line

Doesn't allowing a user mode program to access kernel space memory and execute the IN and OUT instructions defeat the purpose of having CPU modes?

Why is computing ridge regression with a Cholesky decomposition much quicker than using SVD?

How to draw cubes in a 3 dimensional plane

If I receive an SOS signal, what is the proper response?

What's wrong with this bogus proof?

Should I take out a loan for a friend to invest on my behalf?

What problems would a superhuman have whose skin is constantly hot?

What are the practical Opportunity Attack values for a bugbear, holding a reach weapon, with the Polearm Master feat?

Virginia employer terminated employee and wants signing bonus returned

Why does liquid water form when we exhale on a mirror?



selenium Promise while expecting a string to be returned



2019 Community Moderator ElectionWhy does ++[[]][+[]]+[+[]] return the string “10”?Not able to add Recipient and not able to printSelenium Web Driver Eclipse: Passing the username and password from json file or xml fileSelenium.Unable to enter username and password for a websiteLogging in using Javascript and Selenium Webdriver (Chrome)Node Js printing before executionSelenium Java Appium Http proxySelenium example using Node.js from MDN not working?How to make the selenium webdriver script to wait for backend api request to return a response?










0















I am having issues with selenium. I have output a modal that is popping up with a string from a submitted request. I am looking to use findElement to grab that data using the xpath, and return the string to the console. It looks like the promise is not resolved, and I'm not sure how to wrap this in a promise so I get the result of that promise.



DevTools listening on ws://127.0.0.1:60822/devtools/browser/a2114051-85ec-47d7-9d62-9f9809ef732c



Test passed



Forms



Promise < Pending>



 var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until;

USERNAME = 'XXXXXX';
PASSWORD = 'XXXXXXXX';
WEBSITE = 'https://XXXXXXXXXXXXXX/';
var driver = new webdriver.Builder()
.forBrowser('chrome')
.build();
//tag[text()=’text value‘]


driver.get(WEBSITE);


driver.sleep(4000).then(function()
driver.findElement(By.id('username')).sendKeys(USERNAME);
driver.findElement(By.id('password')).sendKeys(PASSWORD);
driver.findElement(By.id('submit1')).click();
);


driver.sleep(26000).then(function()
driver.getTitle().then(function(title)
if (title === 'Forms')
console.log('Test passed');
console.log(title);
driver.findElement(By.xpath("//*[text() = 'Request']")).click();
//driver.findElement(By.id('market')).selectBuyValue('CI').click();
//*[@id="request"]/div[3]/div/input
driver.sleep(4000).then(function()
driver.findElement(By.xpath("//*[@id='market']")).sendKeys("CI");
driver.findElement(By.xpath("//*[@id='request']/div[3]/div/input")).click();
);
driver.sleep(10000).then(function()

console.log(driver.findElement(By.xpath("//*[@id='myModal']/div/div/div[1]/div")).getText());

//THIS WORKS driver.findElement(By.xpath("//*[@id='myModal']/div/div/div[2]/button")).click();
);


else
console.log(title);
console.log('took to long');


);
);









share|improve this question


























    0















    I am having issues with selenium. I have output a modal that is popping up with a string from a submitted request. I am looking to use findElement to grab that data using the xpath, and return the string to the console. It looks like the promise is not resolved, and I'm not sure how to wrap this in a promise so I get the result of that promise.



    DevTools listening on ws://127.0.0.1:60822/devtools/browser/a2114051-85ec-47d7-9d62-9f9809ef732c



    Test passed



    Forms



    Promise < Pending>



     var webdriver = require('selenium-webdriver'),
    By = webdriver.By,
    until = webdriver.until;

    USERNAME = 'XXXXXX';
    PASSWORD = 'XXXXXXXX';
    WEBSITE = 'https://XXXXXXXXXXXXXX/';
    var driver = new webdriver.Builder()
    .forBrowser('chrome')
    .build();
    //tag[text()=’text value‘]


    driver.get(WEBSITE);


    driver.sleep(4000).then(function()
    driver.findElement(By.id('username')).sendKeys(USERNAME);
    driver.findElement(By.id('password')).sendKeys(PASSWORD);
    driver.findElement(By.id('submit1')).click();
    );


    driver.sleep(26000).then(function()
    driver.getTitle().then(function(title)
    if (title === 'Forms')
    console.log('Test passed');
    console.log(title);
    driver.findElement(By.xpath("//*[text() = 'Request']")).click();
    //driver.findElement(By.id('market')).selectBuyValue('CI').click();
    //*[@id="request"]/div[3]/div/input
    driver.sleep(4000).then(function()
    driver.findElement(By.xpath("//*[@id='market']")).sendKeys("CI");
    driver.findElement(By.xpath("//*[@id='request']/div[3]/div/input")).click();
    );
    driver.sleep(10000).then(function()

    console.log(driver.findElement(By.xpath("//*[@id='myModal']/div/div/div[1]/div")).getText());

    //THIS WORKS driver.findElement(By.xpath("//*[@id='myModal']/div/div/div[2]/button")).click();
    );


    else
    console.log(title);
    console.log('took to long');


    );
    );









    share|improve this question
























      0












      0








      0








      I am having issues with selenium. I have output a modal that is popping up with a string from a submitted request. I am looking to use findElement to grab that data using the xpath, and return the string to the console. It looks like the promise is not resolved, and I'm not sure how to wrap this in a promise so I get the result of that promise.



      DevTools listening on ws://127.0.0.1:60822/devtools/browser/a2114051-85ec-47d7-9d62-9f9809ef732c



      Test passed



      Forms



      Promise < Pending>



       var webdriver = require('selenium-webdriver'),
      By = webdriver.By,
      until = webdriver.until;

      USERNAME = 'XXXXXX';
      PASSWORD = 'XXXXXXXX';
      WEBSITE = 'https://XXXXXXXXXXXXXX/';
      var driver = new webdriver.Builder()
      .forBrowser('chrome')
      .build();
      //tag[text()=’text value‘]


      driver.get(WEBSITE);


      driver.sleep(4000).then(function()
      driver.findElement(By.id('username')).sendKeys(USERNAME);
      driver.findElement(By.id('password')).sendKeys(PASSWORD);
      driver.findElement(By.id('submit1')).click();
      );


      driver.sleep(26000).then(function()
      driver.getTitle().then(function(title)
      if (title === 'Forms')
      console.log('Test passed');
      console.log(title);
      driver.findElement(By.xpath("//*[text() = 'Request']")).click();
      //driver.findElement(By.id('market')).selectBuyValue('CI').click();
      //*[@id="request"]/div[3]/div/input
      driver.sleep(4000).then(function()
      driver.findElement(By.xpath("//*[@id='market']")).sendKeys("CI");
      driver.findElement(By.xpath("//*[@id='request']/div[3]/div/input")).click();
      );
      driver.sleep(10000).then(function()

      console.log(driver.findElement(By.xpath("//*[@id='myModal']/div/div/div[1]/div")).getText());

      //THIS WORKS driver.findElement(By.xpath("//*[@id='myModal']/div/div/div[2]/button")).click();
      );


      else
      console.log(title);
      console.log('took to long');


      );
      );









      share|improve this question














      I am having issues with selenium. I have output a modal that is popping up with a string from a submitted request. I am looking to use findElement to grab that data using the xpath, and return the string to the console. It looks like the promise is not resolved, and I'm not sure how to wrap this in a promise so I get the result of that promise.



      DevTools listening on ws://127.0.0.1:60822/devtools/browser/a2114051-85ec-47d7-9d62-9f9809ef732c



      Test passed



      Forms



      Promise < Pending>



       var webdriver = require('selenium-webdriver'),
      By = webdriver.By,
      until = webdriver.until;

      USERNAME = 'XXXXXX';
      PASSWORD = 'XXXXXXXX';
      WEBSITE = 'https://XXXXXXXXXXXXXX/';
      var driver = new webdriver.Builder()
      .forBrowser('chrome')
      .build();
      //tag[text()=’text value‘]


      driver.get(WEBSITE);


      driver.sleep(4000).then(function()
      driver.findElement(By.id('username')).sendKeys(USERNAME);
      driver.findElement(By.id('password')).sendKeys(PASSWORD);
      driver.findElement(By.id('submit1')).click();
      );


      driver.sleep(26000).then(function()
      driver.getTitle().then(function(title)
      if (title === 'Forms')
      console.log('Test passed');
      console.log(title);
      driver.findElement(By.xpath("//*[text() = 'Request']")).click();
      //driver.findElement(By.id('market')).selectBuyValue('CI').click();
      //*[@id="request"]/div[3]/div/input
      driver.sleep(4000).then(function()
      driver.findElement(By.xpath("//*[@id='market']")).sendKeys("CI");
      driver.findElement(By.xpath("//*[@id='request']/div[3]/div/input")).click();
      );
      driver.sleep(10000).then(function()

      console.log(driver.findElement(By.xpath("//*[@id='myModal']/div/div/div[1]/div")).getText());

      //THIS WORKS driver.findElement(By.xpath("//*[@id='myModal']/div/div/div[2]/button")).click();
      );


      else
      console.log(title);
      console.log('took to long');


      );
      );






      javascript selenium selenium-webdriver promise






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 6 at 14:41









      SwimJimSwimJim

      27110




      27110






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Both driver.findElement() and WebElement.getText() methods return a promise, so you will have to either await the call in an async function - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function - or increase your callback hell by calling the then() method like you do with the other promise instances.






          share|improve this answer
























            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%2f55025709%2fselenium-promise-pending-while-expecting-a-string-to-be-returned%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














            Both driver.findElement() and WebElement.getText() methods return a promise, so you will have to either await the call in an async function - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function - or increase your callback hell by calling the then() method like you do with the other promise instances.






            share|improve this answer





























              0














              Both driver.findElement() and WebElement.getText() methods return a promise, so you will have to either await the call in an async function - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function - or increase your callback hell by calling the then() method like you do with the other promise instances.






              share|improve this answer



























                0












                0








                0







                Both driver.findElement() and WebElement.getText() methods return a promise, so you will have to either await the call in an async function - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function - or increase your callback hell by calling the then() method like you do with the other promise instances.






                share|improve this answer















                Both driver.findElement() and WebElement.getText() methods return a promise, so you will have to either await the call in an async function - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function - or increase your callback hell by calling the then() method like you do with the other promise instances.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 7 at 17:01

























                answered Mar 6 at 15:24









                Joao PereiraJoao Pereira

                13510




                13510





























                    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%2f55025709%2fselenium-promise-pending-while-expecting-a-string-to-be-returned%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

                    Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                    Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                    Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved