Script Extensions: Creating a Custom Zip Code Checkpoint
Develop | Posted October 15, 2008

Have you ever wished that there was a checkpoint in TestComplete that performed an action specific to your unique testing needs? Well, with script extensions, now you can create your own custom checkpoints. In this article, I'll demonstrate how to create a custom checkpoint that verifies US Zip Codes are in the correct format.

Planning the Zip Code Checkpoint

Here are the criteria I used when outlining my checkpoint:
  1. Users should be able to easily select the zip code field they are working with
  2. Zip codes should be formatted as 5 digits (e.g., 12345) or as 5 digits followed by a dash and 4 more digits (e.g., 12345-6789).
  3. A message should be written to the TestComplete log stating whether or not the indicated field had a properly formatted zip code.

With that information, we can begin writing the checkpoint.

Creating the Checkpoint

To create the zip code checkpoint, I'll start out by creating a form so I can easily select the zip code fields I want to work with. To do that, I'll add the User Forms item to my TestComplete project. Then I'll create the form as shown in this screenshot.

The following table lists the controls I placed on the form, what I named each control, and the relevant properties I set.

TcxLabel lblMessage Caption:
Select the Zip code field you wish to validate
TcxTextEdit txtZipCodeField

Text: [set to blank]

Read Only: True
TcxButton cmdOK

Caption: OK

Modal Result: mrOK
TcxButton cmdCancel Caption: Cancel

Modal Result: mrCancel

TObjectPicker zipPicker

For the zipPicker control, I added an event called zipCodeForm_zipPicker_OnObjectPicked. Don’t worry about writing code for that yet; we’ll handle that in the next section.

With the form created, we make the form usable in an extension by right clicking on it and selecting Export to File. I exported my form as c:zipcodeCheckpointzipCodeForm.aqfrm.

Exporting a Form

Next, we need to write the code for our extension. Below
is the complete JScript source (including comments) for the zip code

Creating an Icon

Now, I want to be able to just click a button on a toolbar to display my zipcode form. To do that, I need an icon for my button. I’ll be the first to admit that art isn’t my strong suit, so the icon I created is very simple. I just fired up Paint .NET and created a 16x16 bmp file. Inside that file, I’m going to type the word ZIP in 6pt font, and save it as c:zipcodecheckpointzipicon.bmp. Here’s the icon I created:
Zip Code Icon

Gorgeous, no? :)

Creating the Description File

We also need to create a description file for our
checkpoint, as shown below:

There are a couple of tags worth explaining here:

RecordAction – Information used when this extension is
invoked during recording

DesignTimeAction – Information used when this extension
is invoked during design time.

RuntimeObject – this tag puts the ZipCodeCheckpoint
option in TestComplete’s code completion list.

These tags have some common attributes:

Name - the tooltip that will be displayed for the

Icon – the icon that will be shown on the toolbar for
this extension

Routine - the script routine that will be called for this

Packaging the Extension

Unlike “traditional” plug-ins that need to be compiled,
the extension’s source files just need to be packed into a ZIP archive. The
archive extension should then be changed to tcx (TestComplete extension).
That’s all, no other installation preparations are needed.

You can download the package here.

Installing the Extension

To install our newly created zipcode checkpoint, just
copy the tcx file you just created to the ScriptExtensions directory in your
TestComplete installation folder. ([TestComplete]BinExtensionsScriptExtensions)

Using the Extension

Once the Extension is installed, you can create zip code
checkpoints while you’re recording or during design time. Just click the button
on the Extension toolbar to display our zip code checkpoint form.

Zip Code Toolbarbutton

Then pick the control you want to work with and click OK. The zip code checkpoint will be added to your script.

You can also just type the following command into the


Where objectName is the object you wish to verify, and
property is the property on that object that contains the text.

A Note

You’ll notice that by default I’m validating the wText
property. In some cases, this property may not be relevant – you may want to
use the value property on an HTML control, or the WndCaption on a C++ based
control. In that case, you just need to
change “wText” to “value” or “WndCaption”.


So that’s how easy it is to create your own custom checkpoint
in TestComplete. There are many other variants on what I’ve done here. You
could adapt this checkpoint so it could be used to verify credit card numbers
are in the correct format, or to verify social security numbers are correctly
formatted. My next article will show how to create a checkpoint that verifies a
list of files are present in a given directory. Until then – onward automation!


By submitting this form, you agree to our
Terms of Use and Privacy Policy

Thanks for Subscribing

Keep an eye on your inbox for more great content.

Continue Reading

Add a little SmartBear to your life

Stay on top of your Software game with the latest developer tips, best practices and news, delivered straight to your inbox