Forum Discussion

DIMWSH's avatar
DIMWSH
New Contributor
7 years ago

Comparing object inner text to Excel data in VBScript using DDT Driver

The following script obtains the inner text of an object in a web application and checks to see if the contents are equal to a column in an Excel document. The driver script is where I'm using the DDT Driver to obtain the Excel values.

 

It's getting the values from both the application and Excel, but I get an error every time. I used msgbox to obtain the values of the two variables, and I put them into Beyond Compare to make sure the values are equal, and they are. Even though the values are equal, the script is still logging an error. 

 

Any thoughts?

 

Function CodeVerify (chktext)

'Setting the drop down object
Set chkObj = Aliases.browser.ClassPage.ClassHeader.ClassBox.ClassInfo.ClassDropdown

'Obtaining the inner text of the drop down
chkTxt=chkObj.innerText

 

'Chktext is a variable that is passed when the script is run, this is the column in the Excel sheet where the drop down requirements are stored.
exptxt=chktext

 

'Exptxt should be the drop down requirements in the Excel Sheet and it should equal chkTxt.

If exptxt = chkTxt Then
Log.Checkpoint "Codes have been verified"
Else
Log.Error "Codes have not been verified"
End If
End Function

2 Replies

  • baxatob's avatar
    baxatob
    Community Hero

    1. Be sure that your DDT driver returns the string type value from the Excel file

    2. Use contentText property instead of innerText - it's a common recommended rule for web testing using TestComplete.

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      In addition to what baxatob says, there may be non-printing characters in the innerText, even the contentText, that may cause a difference.  Try examining the item directly in TestComplete object spy and see what possible line breaks, carraige returns, etc., might be there.