Forum Discussion

royd's avatar
royd
Regular Contributor
8 years ago
Solved

GetAttribute not working! Help!

TestComplete 12.2 and IE11

 

I have a script that isolates security code from email (thanks to Shanker_R). It had worked without any trouble in the past. It stopped working now! The problem stems from not being able to retrieve the massage from email. Here is the code I am using:

 

var massageCell = Aliases.browser.pageMailinator.panelMsg.mTable.mCell;
var massageString = massageCell.GetAttribute("contentText");
Log.Message(massageString);
  

 

The Log is empty! I would really appreciate any help I can get.

 

Thanks

 

Dave

  • Okay, I finally figured it out! "getAttribute" works only with native web objects! I used "contentText" and resulted blank log!!

     

    Replaced contentText with innerText and it worked! Lesson learned!

     

    Thank you Shankar and Karthik for your efforts. I really appreciate.

     

    Dave

8 Replies

  • roydplease aqConvert.VarIntoStr(massageString)

    and please check message context is not null

    Example

    var massageCell = Aliases.browser.pageMailinator.panelMsg.mTable.mCell;
    var massageString = massageCell.GetAttribute("contentText");
    var msg = aqConvert.VarIntoStr(massageString )
    if (msg != "")
    {
    log.message(msg)
    }
    or
    var massageString = massageCell.GetAttribute("contentText");
    changes as var massageString = massageCell.contentText;

     

  • shankar_r's avatar
    shankar_r
    Community Hero

    I guess the mail format may have changed in the cell level.

     

    So, Put a breakpoint in the below line and share us what you got. So that we will get know whether it is related to object or someother things.

     

    Log.Message(massageString);

     

    • royd's avatar
      royd
      Regular Contributor

      Hi Shakar

       

      The log is empty. No errors.

      • royd's avatar
        royd
        Regular Contributor

        Okay, I finally figured it out! "getAttribute" works only with native web objects! I used "contentText" and resulted blank log!!

         

        Replaced contentText with innerText and it worked! Lesson learned!

         

        Thank you Shankar and Karthik for your efforts. I really appreciate.

         

        Dave