Forum Discussion

mikej411's avatar
mikej411
Occasional Contributor
9 years ago
Solved

How to represent End Line in a String for TestComplete using Javascript

I need to verify a warning message in TestComplete that has multiple lines for it's innerText property. The innerText looks like this:   First Line Second Line To do that, I thought using \n wou...
  • mikej411's avatar
    mikej411
    9 years ago

    So I found 2 solutions:

    1. I used contentText property as suggested above. This passes only when I include one "\n". My warning label has 3 line-breaks when visually verifying, so this method doesnt accurately verify the message. See below:

     

     if(warningMessage.contentText== "First Line\nSecond Line")
        Log.Checkpoint("Pass");
      else
        Log.Error("Fail"); 

     

    2. The next solution is using the innerText property, but instead of "\n", I have to use "\r\n". I'm not sure why this works, as it was just a suggestion in another forum

     

     if(warningMessage.innerText== "First Line\r\n\r\n\r\nSecond Line")
        Log.Checkpoint("Pass");
      else
        Log.Error("Fail");