Protractor: getText() returns empty string from a particular element

Created on 10 Nov 2017  路  1Comment  路  Source: angular/protractor

Dear Protractor Community,
Thank you for the support that I always get reading your posts.
I have the following problem:
I need to get string form this element:
image
image
This is the implementation for getting it:

   var text = "";   
this.getQR = function(){
    var str1 = '{"qrCode": "';
    var str2 = '"}';
    var token = "eyJ0eXAiOiJKV1Ac7JKuZfB-ceUE"

    var qrCode = "";
        var qr = elem.qrCodeValue.getText().then(function(code) {
       return code;
       });
       qr.then(function(text) {
       qrCode = text
       var code = str1.concat(qrCode, str2);

Implementation works fine and returns string for an element with hard coded string. But this one is dynamic and in this particular case I get empty string.
Locators used:
this.qrCodeValue = element(by.css(#qr-code-value'));
or
this.qrCodeValue = element(by.css('.qr-container div div div'));
What I鈥檓 doing wrong? Please advise me how I can get it. I need to use the qr code later to login to the web application via API call and now I鈥檓 stacked.
Thank you in advance.

Most helpful comment

Managed to find how to get it here:
https://stackoverflow.com/questions/25845938/protractor-gettext-returns-empty-string-for-non-empty-element
.getAttribute('textContent') works for me.
Closing this issue.

>All comments

Managed to find how to get it here:
https://stackoverflow.com/questions/25845938/protractor-gettext-returns-empty-string-for-non-empty-element
.getAttribute('textContent') works for me.
Closing this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

luakri picture luakri  路  3Comments

rafalf picture rafalf  路  3Comments

davidkarlsen picture davidkarlsen  路  3Comments

tmeneau picture tmeneau  路  3Comments

psech picture psech  路  3Comments