Specifying Tags

This functionality is available only for projects or scripts that use the Classic Agent.

When you are recording declarations, you can select any combination of tags to record by selecting check boxes in the Tag Information group box in the Record Window Declarations dialog box. You can record different tags for different objects. You can also specify which tags you want recorded by default.

Default tags

You can record more than one tag for an object. Doing so makes scripts less sensitive to changes when the tests are run. For example, if you record a caption and a window ID for a control, then even if the caption on the control changes (such as the caption "Case sensitive" changing to "Case is significant"), Silk Test Classic can still find the control based on its window ID.

This is particularly an issue in situations where captions change dynamically, such as in MDI applications where the window title changes each time a different child window is made active.

By default, when you record window declarations, each object is given two tags: the caption (if there is one) and the Window ID (if there is one).

Note: Two tags are checked in the Tag Information box of the Record Declarations dialog box: Caption and Window ID.

For example, here is the default recorded declaration for the Case sensitive check box:

CheckBox CaseSensitive
   multitag "Case sensitive"
		   "$1041"

Silk Test Classic specifies multiple tags in a declarations file using the multitag statement. In the previous example, the check box is declared with two tags:

  • The string "Case sensitive", which is its caption.
  • The string "$1041", which is its Window ID.

Using class-specific multiple tags

You can specify which multiple-tag types to use for an individual class. For example, maybe you don’t want window ID used with a particular class, even though you want window ID used with all other classes. You can specify this by including a setting statement in the declaration for the class.

For additional information, see the winclass Declaration.

Multiple tags at runtime

When running your test cases, the Agent tries to resolve each part of a multiple tag from top to bottom until it finds an object that matches.

Consider this declaration:

CheckBox CaseSensitive
   multitag "Case sensitive"
		   "#1"

When Silk Test Classic encounters a reference to Find.CaseSensitive, it first looks for a check box whose caption is "Case sensitive". If it finds one, it uses it. If it doesn’t find one, it looks for the first check box in the dialog box (because of the index tag "#1"). If there is one, Silk Test Classic uses it. If none of the tags resolve, an exception is raised.

For complete information about tag resolution, see multitag Statement.

Changing tags

Sometimes you need to change tags from what Silk Test Classic named them by default.

Why change the tags

By default, the GUI object’s caption and index are used for the tag, because they are the most portable. In most cases, these are what you want to use.

However, there are situations in which the default tag is not suitable.

Example: Changing a tag

You might want to provide more than one caption for a control if the control’s caption can change dynamically. For example, if a push button sometimes says Yes and sometimes says Continue, you could change the tag as shown here:

PushButton Confirm
		  multitag "Yes"
  "Continue"

The Agent would find the pushbutton if it had either caption.

To separate different tag components, use the pipe character: |.