TestComplete Tip #1

Wed 23rd Feb 2011

I’ve been getting an error testing one of our applications written in Delphi 5 using SmartBear/AutomtedQA TestComplete. When working with an existing keyword test, I remapped a TDbGrid control and when I went to save it, I kept getting this error:

Could not convert variant of type (Null) into type (Integer)

Very frustrating, as I the script would not save because of the error, so I couldn’t even send an example of the problem to Tech Support. After hunting around for a while, I traced it down to the Object Map. One of the properties in there was set to Null, and TestComplete was apparently trying to convert the Null into an Integer to save the script.

I deleted the object from the Object Map and was able to save and run the test. But because the mapping was now gone, the control could not be identified. When I remapped the control, the error came back. Doh!

After messing around with for another hour or two, I worked out the solution:

1) When recording TestComplete tests for Delphi 5 applications, turn off object mapping:
Go to Tools | Options | Name Mapping, and uncheck the 2 check boxes here

2) Delete any object map that’s already been created (optional).

3) Re-identify any controls in your test scripts.

Step 3 took me a long time, as we’d already recorded a lot scripts. But it had another nice side-effect. I’d found that tests using mapped objects are unreliable. They’ll work fine time after time, and then, for no reason, just fail to identify objects at run time.

When objects are not mapped, TestComplete evaluates them each run using the Delphi 5 control name hierarchy, and it finds the object pretty much every time. It means your test scripts are a bit wordier, but I’ve found it to be much more reliable.

Happy testing,
Frank.