Powered by: Dharamveer Saxena

Tuesday, June 29, 2010

How to handle null strings

In TestComplete whenever DDT diver or array or anything returns null or nothing instead of a string value then it gives error message. For example if you are fetching values using the DDT driver as follow it will return you the data string from the excel file if the value exists:

'path is the path of axcel file
'sheet is the sheet ID of excel file
'A is the column name in excel file

set inputdata = DDT.ExcelDriver(path,sheet)
name = inputData.value("A")

In case if it does not exists then, it will trough an error/exception. You can handle it versy easily by using &"" with the string.

set inputdata = DDT.ExcelDriver(path,sheet)
name = inputData.value("A") &"" 'this will add nothing but will remove the exception you are getting.

No comments:

Post a Comment