Forum Discussion

FRin323's avatar
FRin323
Occasional Contributor
10 years ago

textContent Property Match But Don't?

Hello!

 

I'm really confused as how this is even possible? I've made sure there are no trailing spaces and as you might be able to tell from the numeration, this is the 4th link in the panel that was evaluated which I think means the other links before did not have the same issue. Any help?

 

Test Complete Version 11.30.2298.7

Windows 7 Enterprise Service Pack 1 64-bit

 

(Tried to insert screenshot attached but it's not working for some reason...)

 

10 Replies

  • I have a function (vbscript) that will compare two strings at the ASCII level, this may tell you where the differences lie (also attached in a text file with proper indentation).

     

    Hope this helps

     

    Dave

     


    'Description:  Compares the ASCII Values of two strings and highlights differences
    'Parameters:   pString1 - first piece of text to compare
    '            pString2 - second piece of text to compare
    Sub CompareAsciiValuesOfText(pString1, pString2)
     Dim aString1(), aString2()
     Dim sThisLetter, sThisAsc
     Dim iEnd
     
      call Log.AppendFolder("Analysing string differences","CompareAsciiValuesOfText() Looking at the ASCII values of the strings")

     'Code doesnt handle empty strings so exit
     If pString1 = "" or pString2 = "" Then
      Log.Message "Empty string", "PrintAndCompareAsciiValuesOfText() pString1 or pString2 is empty - code doesn't handle this, exiting sub."
      call Log.PopLogFolder
      Exit sub
     End If

     Dim x
     For x = 1 to len(pString1)
      ReDim Preserve aString1(x)
      sThisLetter = mid(pString1,x,1)
      sThisAsc = Asc(sThisLetter)
      aString1(x) = "ASCII Letter= " & sThisLetter & chr(13) & "ASCII number=" & sThisAsc
     Next

     For x = 1 to len(pString2)
      ReDim Preserve aString2(x)
      sThisLetter = mid(pString2,x,1)
      sThisAsc = Asc(sThisLetter)
      aString2(x) = "ASCII Letter= " & sThisLetter & chr(13) & "ASCII number=" & sThisAsc
     Next

     If ubound(aString1) = ubound(aString2) Then
      call Log.Message("String lengths are the same ","Length of both strings: " & ubound(aString1))
     else
      call log.Warning("String lengths are different","Length of String1: " & ubound(aString1) & chr(13) & "Length of String2: " & ubound(aString2))
     End If

     'now loop through them both - we can only end at the shortest string
     If ubound(aString1) > ubound(aString2) Then
      iEnd = ubound(aString2)
     else
      iEnd = ubound(aString1)
     End If
     For x = 1 to iEnd
      'highlight any differences in characters
      If aString1(x) <> aString2(x) Then
       call log.Warning ("Mismatch at character position " & x,"String 1:" & chr(13) & Left(pString1,x) & chr(13) & chr(13) & "String 2:" & chr(13) & Left(pString2,x))
       call log.Warning ("ASCII details","String 1 position " & x & ":" & chr(13) & aString1(x) & chr(13) & chr(13) & "String 2 position " & x & ":" & chr(13) & aString2(x))
      End If
     Next
     call Log.PopLogFolder
    End Sub

     

  •  Hi,

     

    The difference in string is the first probable cause, agreed. I usually use an online tool (http://www.textdiff.com/) to compare stings, one needs to be careful to copy correctly for hidden characters as well.

     

    - Ali

     

  • Hi,

     

    String mismatch:

    - Sometimes there are 'leading' spaces as well, but I'm sure you might have checked that as well.

    - Secondly at times TestComplete changes special characters on its own. I know for some objects the "$" sign turning to "_".

     

    Different object

    - Since the objects are dynamic with panels all over the place, it could be TestComplete is capturing and comparing different object than the one you want to check. I cannot tell from the name map shown, there are 6 panels in total shown, I would suggest to use verify the object name of the original object you want to capture using object spy and compare with the parent objecct map name given here.

     

    Let me know what comes up!

  • Is the text all on one line in the application?

     

    I have had issues like that where the strings look the same, but there was actually a new line character that wasn't obvious to me just looking at the string (it just looked like a space).

     

    • FRin323's avatar
      FRin323
      Occasional Contributor

      cshukusky wrote:

      Is the text all on one line in the application?

       

      I have had issues like that where the strings look the same, but there was actually a new line character that wasn't obvious to me just looking at the string (it just looked like a space).

       


      Yes, it's the text in a drop down menu entry. 

      • Add some code before the checkpoint.  Print out the length of the string in the stored object and from app object.  Convert the strings to arrays of characters (JScript: myArray = string.split("")).  Compare the arrays.  If still no difference detected, look at the character codes of the characters (string.charCodeAt()).