[SilkTest]Overview of tags

来源:互联网 发布:武汉java培训机构名单 编辑:程序博客网 时间:2024/05/01 23:50
 

  When to record classes
  Consider these criteria when deciding whether to record classes for Java objects. When you record classes, SilkTest derives tags from the Java class name.

Am I testing only predefined Java classes?
  If you are testing only predefined Java classes, then you do not need to record additional classes. Check the list of predefined Java classes to be sure.  If you want to access native methods for predefined Java classes, then you must remove the existing definition and re-record the class.

Am I testing visible custom controls?
  If you are testing custom Java controls that are not predefined, then you must record classes for these controls. In this case, the custom controls are visible, but appear as CustomWin objects. After you record the class, you can retrieve information about any number of instances(objects) of that class.

Do I want to test custom controls that are currently ignored?
   To maintain efficiency during the recording process, SilkTest ignores custom Java controls that are not considered relevant for testing, such as containers or panels. Ignored objects are not recognized at all by SilkTest, not even as CustomWin objects.
  Even so, you can expose and record classes for ignored Java objects in standone Java applications or in Java applets that you consider important for testing purposes. See Recording classes for ignored Java objects.

Have I modified an existing class definition?
  If you add, delete or modify any native methods or parameters for a custom Java class, you need to either re-record the class or modify your class include file to reflect the changes.

 


multitag statement

   Action
       In a window declaration, defines one or more tags that the Agent uses internally to uniquely identify the object at runtime. By default, the Agent generates multitag statements for GUI objects when you record window declarations.
          Note
               Never use the tag in your scripts to refer to an object; always use the object's identifier.

   Syntax
        [gui-specifier] multitag tag-string
                              [tag-string]
                               ...            

Variable Description gui-specifier Optional. Specifies the GUIs that the statement applies to.
      See window declaration. If omitted, the statement applies to all GUIs. tag-string A STRING expression that evaluates to the object's tag.
You can specify as many tag-strings as you want. The tag can be expressed in several ways, as described below.

 
   Forms for the tag-string argument
      
The tag-string argument can express the object's tag in one of five ways:

Tag type Description Caption The caption or label as it appears to the user. Prior text  The closest static text above or to the left of the object.  You must use the ^ character to preface a prior text tag. Index The order(from top left to bottom right) in relation to its sibling objects of the same class. Index tags must begin with # character. Window ID GUI-specific ID. You must use the $ cahracter to preface a window Id tag. Location The physical location, expressed as a pair of (x, y) coordinates. you must use the @ character to preface a loation tag.



   Example
      
The check box in the Find dialog in the TextEditor has these possible tags(displayed inthe record Window Declarations dialog):

Tag type Description Comment Caption Case sensitive The label for the check box. Prior text   ^Find What: The closest static text above the check box. Index #1   Window ID $1041 GUI-specific tag. Location  @(57, 65) (x, y) location of the check box in the dialog

   What is recorded by default
      By defult, when you generate window declarations, the Agent generates tags based on the object's caption(if it has one) and window ID(if it has one).

   Specifying additional tag-strings
      You can specify as many tag-strings as you want in a multitag statement. You can even specify more than one value for each tag type. For example, if a control's caption can change dynamically, you would want to specify each valid caption in its tag, such as:

PushButton Confirm
   multitag 
"Yes"
   
"OK"

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

   How to choose a tag-string form
      
The caption form for the window tag is the most portable. Along with the index, this is the form that the Agent uses by default when it creates tags for recorded declarations.
      The Agent automatically generates valid, unique tags. However, in some situations you might want to edit the tags. The following table describes which form of the tag to use in specific situations:
  In this situation Use this form for the tag The GUI object's label contains dynamic text. For example the third text string in a dialog is labeled with the path c:/myapp. The index, for example: "#3".
Note: Avoid using the index format for objects of the MoveableWin class. This syntax may result in your choosing a window at random in cases where there are multiple windows.
The GUI object's parent can vary at runtime. For example, the Open dialog can have more than one application as a parent at runtime. Specify that the parent is the currently active application, for example:
   "~ActiveApp/[DialogBox]Open"  You want to assign the tag dynamically at runtime.

 Replace the tag with a function call. For example, where CreateTag is a user-defined function that returns a string:
    MenuItem CheckBox
        tag CreateTag(this)
    ...

    STRING CreateTag(WINDOW wWindowIdentifier)
         switch (wWindowIdentifier)
          case TestApp.Control.CheckBox
                return "Check Box|$200"

Two dialogs have the same label or caption, but do not have identical contents. For example, one Open dialog has a Name text field and the other Open dialog has a Search pushbutton. Specify the tag of a unique child in each tag. You may use any unambiguous tag form for the child, but do not use the window identifier of the child. For example,
 "[DialogBox]Open/[TextField]First Name/..."
  "[DialogBox]Open/[PushButton]New Search/..."
  "[DialogBox]Open/[ComBox] #2/..."
The GUI object has no label or caption and the position(and hence the index) can change dynamically at runtime. The window ID. The Gui object has a label or caption, but you don't want to use it as the tag because it is changeable for this object. The index or prior text. You need to internationalize your application. The window ID, or replace the tag with a variable. The GUI object is a graphical control like a tool bar. The location. You want to invoke a dialog, not the main window, when your application starts. For example, you want to invoke a dialog named Login. Change the class of the dialog from DialogBox to MainWin, and then specify the real class in the tag, for example:
    "[DialogBox]Login" More than one instance of the window might be displayed at one time Use the instance syntax, which takes the form tag-string[n], where [n] refers to the instance. [1] refers to the instance of the window that is closest to the top on the desktop, [2] refers to the instance that is next highest to the top, and so on.
For example, you could have one declaration for the window whose tag is "MyWindow[1]" and another declaration whose tag is "MyWindows[2]". With these declarations, you can record and play back tests against two instances of the sam window. Note that when an instance of the window becomes active, it automatically becomes MyWindow[1].

The Agent automatically accounts for dynamic strings in the caption of a main window(for example, file names) and replaces these dynamic strings with the wildcard character "*".

    Tag syntax
       
The examples in the table above use these syntactic elements:
This syntactic element Is used in a tag to / Separate a parent from a child object. [  ] Delimit the class or instance of a GUI object. .. Specify that the Agent should use the parent of the child object in the tag. ~ActiveApp Specify that the top-level parent of a GUI object is the currently active application at runtime. * Represent dynamic strings in the caption of a main window(for example, file names) | Delimit segments of a multiple tag. ~ Force SilkTest to examine the next level of a multiple tag. Used in conjunction with the | element. without the ~, SilkTest only evaluates the first segment of a multitag.

 
原创粉丝点击