Forum Discussion

David_D's avatar
David_D
Senior Member
4 years ago

Type Mismatch Error solution?

Data-Driven test using Excel as a data source.

 

Test Case: Updating a street address.

 

Street Address 1 is required. 

Street Address 2 is optional.

 

Implementation:

A Keyword Test accesses an Excel sheet and passes the cell values as parameters to keyword tests (UpdateStreetAddress1 and UpdateStreetAddress2).

 

Since Street Address 2 is optional, my first attempt was to leave Street Address 2 empty in the Excel sheet.  This triggers a Type Mismatch when UpdateStreetAddress2 is called as it is expecting a String.

 

My solution:

 

The calling Keyword Test would use aqConvert.VartoStr to essentially “type” the value when calling UpdateStreetAddress2.  This works and it would allow me to use aqConvert.VartoInt and/or aqConvert.VartoFloat as appropriate for other datatypes.

 

This seems to me the most straightforward approach, but I'm still learning test complete and perhaps there is a better solution.

 

Comments?

 

  • Welcome to Problems with Excel  😄

     

    If that solution works for you, then go for it.   I've also done things like put a special character in the cells that are meant to be empty so I can check for that character.

     

    Eventually I got tired of the work arounds and switched to using .csv files wherever I could.  I can always view them in Excel if I need to, but my testing copy is .csv

  • Welcome to Problems with Excel  😄

     

    If that solution works for you, then go for it.   I've also done things like put a special character in the cells that are meant to be empty so I can check for that character.

     

    Eventually I got tired of the work arounds and switched to using .csv files wherever I could.  I can always view them in Excel if I need to, but my testing copy is .csv