Value of text field in protractor- undefined












0














I am not able to get value of label (as value is not editable and return by API).
I am using getText, but out put is always undefined. The value of this field is 2222.
using below



var activatedid = element(By.xpath("/html/body/app-root/mat-toolbar/div[3]/div[3]"));
activatedid.getText()
.then(function(text) {
console.log(this.text);









share|improve this question




















  • 1




    The content provided in your post is hardly sufficient to understand the root cause of your problem. Please edit your question and provide an Minimal, Complete, and Verifiable example. For more information, please see How to Ask and take the Tour.
    – quant
    Nov 20 '18 at 8:22










  • @surinder can you edit the question by appending the html ?
    – Bharath Kumar S
    Nov 20 '18 at 10:06










  • first make sure that the field is being displayed using isPresent() - . activatedid.isPresent().then(function(text) { console.log(text);//Will display true or false }); If it is present then check if you dont need to actually get the attribute value instead of text: activatedid.getAttribute('value').then(function(value){ console.log('field value is '+value) })
    – Alexandre
    Nov 20 '18 at 15:03










  • Yeah once you have more details it'll be easier to assume, otherwise here are three shots in the dark: 1) AND THIS IS VERY LIKELY THE CASE - remove this. before text; 2) wrong locator, at least it doesn't seem to be reliable 3) getText() gets only visible text, thus your element could be somewhere down the page
    – Sergey Pleshakov
    Nov 20 '18 at 18:53










  • Actually my (1)^ is your problem for sure, or one of them
    – Sergey Pleshakov
    Nov 20 '18 at 18:54
















0














I am not able to get value of label (as value is not editable and return by API).
I am using getText, but out put is always undefined. The value of this field is 2222.
using below



var activatedid = element(By.xpath("/html/body/app-root/mat-toolbar/div[3]/div[3]"));
activatedid.getText()
.then(function(text) {
console.log(this.text);









share|improve this question




















  • 1




    The content provided in your post is hardly sufficient to understand the root cause of your problem. Please edit your question and provide an Minimal, Complete, and Verifiable example. For more information, please see How to Ask and take the Tour.
    – quant
    Nov 20 '18 at 8:22










  • @surinder can you edit the question by appending the html ?
    – Bharath Kumar S
    Nov 20 '18 at 10:06










  • first make sure that the field is being displayed using isPresent() - . activatedid.isPresent().then(function(text) { console.log(text);//Will display true or false }); If it is present then check if you dont need to actually get the attribute value instead of text: activatedid.getAttribute('value').then(function(value){ console.log('field value is '+value) })
    – Alexandre
    Nov 20 '18 at 15:03










  • Yeah once you have more details it'll be easier to assume, otherwise here are three shots in the dark: 1) AND THIS IS VERY LIKELY THE CASE - remove this. before text; 2) wrong locator, at least it doesn't seem to be reliable 3) getText() gets only visible text, thus your element could be somewhere down the page
    – Sergey Pleshakov
    Nov 20 '18 at 18:53










  • Actually my (1)^ is your problem for sure, or one of them
    – Sergey Pleshakov
    Nov 20 '18 at 18:54














0












0








0







I am not able to get value of label (as value is not editable and return by API).
I am using getText, but out put is always undefined. The value of this field is 2222.
using below



var activatedid = element(By.xpath("/html/body/app-root/mat-toolbar/div[3]/div[3]"));
activatedid.getText()
.then(function(text) {
console.log(this.text);









share|improve this question















I am not able to get value of label (as value is not editable and return by API).
I am using getText, but out put is always undefined. The value of this field is 2222.
using below



var activatedid = element(By.xpath("/html/body/app-root/mat-toolbar/div[3]/div[3]"));
activatedid.getText()
.then(function(text) {
console.log(this.text);






protractor






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 8:25









barbsan

2,14811122




2,14811122










asked Nov 20 '18 at 8:14









surinder kaur

1




1








  • 1




    The content provided in your post is hardly sufficient to understand the root cause of your problem. Please edit your question and provide an Minimal, Complete, and Verifiable example. For more information, please see How to Ask and take the Tour.
    – quant
    Nov 20 '18 at 8:22










  • @surinder can you edit the question by appending the html ?
    – Bharath Kumar S
    Nov 20 '18 at 10:06










  • first make sure that the field is being displayed using isPresent() - . activatedid.isPresent().then(function(text) { console.log(text);//Will display true or false }); If it is present then check if you dont need to actually get the attribute value instead of text: activatedid.getAttribute('value').then(function(value){ console.log('field value is '+value) })
    – Alexandre
    Nov 20 '18 at 15:03










  • Yeah once you have more details it'll be easier to assume, otherwise here are three shots in the dark: 1) AND THIS IS VERY LIKELY THE CASE - remove this. before text; 2) wrong locator, at least it doesn't seem to be reliable 3) getText() gets only visible text, thus your element could be somewhere down the page
    – Sergey Pleshakov
    Nov 20 '18 at 18:53










  • Actually my (1)^ is your problem for sure, or one of them
    – Sergey Pleshakov
    Nov 20 '18 at 18:54














  • 1




    The content provided in your post is hardly sufficient to understand the root cause of your problem. Please edit your question and provide an Minimal, Complete, and Verifiable example. For more information, please see How to Ask and take the Tour.
    – quant
    Nov 20 '18 at 8:22










  • @surinder can you edit the question by appending the html ?
    – Bharath Kumar S
    Nov 20 '18 at 10:06










  • first make sure that the field is being displayed using isPresent() - . activatedid.isPresent().then(function(text) { console.log(text);//Will display true or false }); If it is present then check if you dont need to actually get the attribute value instead of text: activatedid.getAttribute('value').then(function(value){ console.log('field value is '+value) })
    – Alexandre
    Nov 20 '18 at 15:03










  • Yeah once you have more details it'll be easier to assume, otherwise here are three shots in the dark: 1) AND THIS IS VERY LIKELY THE CASE - remove this. before text; 2) wrong locator, at least it doesn't seem to be reliable 3) getText() gets only visible text, thus your element could be somewhere down the page
    – Sergey Pleshakov
    Nov 20 '18 at 18:53










  • Actually my (1)^ is your problem for sure, or one of them
    – Sergey Pleshakov
    Nov 20 '18 at 18:54








1




1




The content provided in your post is hardly sufficient to understand the root cause of your problem. Please edit your question and provide an Minimal, Complete, and Verifiable example. For more information, please see How to Ask and take the Tour.
– quant
Nov 20 '18 at 8:22




The content provided in your post is hardly sufficient to understand the root cause of your problem. Please edit your question and provide an Minimal, Complete, and Verifiable example. For more information, please see How to Ask and take the Tour.
– quant
Nov 20 '18 at 8:22












@surinder can you edit the question by appending the html ?
– Bharath Kumar S
Nov 20 '18 at 10:06




@surinder can you edit the question by appending the html ?
– Bharath Kumar S
Nov 20 '18 at 10:06












first make sure that the field is being displayed using isPresent() - . activatedid.isPresent().then(function(text) { console.log(text);//Will display true or false }); If it is present then check if you dont need to actually get the attribute value instead of text: activatedid.getAttribute('value').then(function(value){ console.log('field value is '+value) })
– Alexandre
Nov 20 '18 at 15:03




first make sure that the field is being displayed using isPresent() - . activatedid.isPresent().then(function(text) { console.log(text);//Will display true or false }); If it is present then check if you dont need to actually get the attribute value instead of text: activatedid.getAttribute('value').then(function(value){ console.log('field value is '+value) })
– Alexandre
Nov 20 '18 at 15:03












Yeah once you have more details it'll be easier to assume, otherwise here are three shots in the dark: 1) AND THIS IS VERY LIKELY THE CASE - remove this. before text; 2) wrong locator, at least it doesn't seem to be reliable 3) getText() gets only visible text, thus your element could be somewhere down the page
– Sergey Pleshakov
Nov 20 '18 at 18:53




Yeah once you have more details it'll be easier to assume, otherwise here are three shots in the dark: 1) AND THIS IS VERY LIKELY THE CASE - remove this. before text; 2) wrong locator, at least it doesn't seem to be reliable 3) getText() gets only visible text, thus your element could be somewhere down the page
– Sergey Pleshakov
Nov 20 '18 at 18:53












Actually my (1)^ is your problem for sure, or one of them
– Sergey Pleshakov
Nov 20 '18 at 18:54




Actually my (1)^ is your problem for sure, or one of them
– Sergey Pleshakov
Nov 20 '18 at 18:54












1 Answer
1






active

oldest

votes


















0














Remove this. before text, so you have



var activatedid = element(By.xpath("/html/body/app-root/mat-toolbar/div[3]/div[3]"));
activatedid.getText()
.then(function(text) {
console.log(text);
})





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%2f53388735%2fvalue-of-text-field-in-protractor-undefined%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














    Remove this. before text, so you have



    var activatedid = element(By.xpath("/html/body/app-root/mat-toolbar/div[3]/div[3]"));
    activatedid.getText()
    .then(function(text) {
    console.log(text);
    })





    share|improve this answer


























      0














      Remove this. before text, so you have



      var activatedid = element(By.xpath("/html/body/app-root/mat-toolbar/div[3]/div[3]"));
      activatedid.getText()
      .then(function(text) {
      console.log(text);
      })





      share|improve this answer
























        0












        0








        0






        Remove this. before text, so you have



        var activatedid = element(By.xpath("/html/body/app-root/mat-toolbar/div[3]/div[3]"));
        activatedid.getText()
        .then(function(text) {
        console.log(text);
        })





        share|improve this answer












        Remove this. before text, so you have



        var activatedid = element(By.xpath("/html/body/app-root/mat-toolbar/div[3]/div[3]"));
        activatedid.getText()
        .then(function(text) {
        console.log(text);
        })






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 20 '18 at 18:55









        Sergey Pleshakov

        19113




        19113






























            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f53388735%2fvalue-of-text-field-in-protractor-undefined%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

            "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

            Alcedinidae

            RAC Tourist Trophy