mikej411
10 years agoOccasional Contributor
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 would be able to represent the end lines
if(warningMessage.innerText == "First Line\n\n\n\nSecond Line") Log.Checkpoint("Pass"); else Log.Error("Fail");
But it failed. How can I verify this warning message?
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");