Validating and Passing Data Back to the Server

The simple validation example uses a plain button control. If a Submit control was used, the example would never see the data to check it — everything would go immediately to the server. Avoiding the Submit control lets you check the data, but it doesn't submit the data to the server. That requires an additional line of code:

<SCRIPT LANGUAGE="VBScript"> 
<!--
Sub Button1_OnClick
 Dim TheForm
 Set TheForm = Document.ValidForm
 If IsNumeric(TheForm.Text1.Value) Then
    If TheForm.Text1.Value < 1 Or TheForm.Text1.Value > 10 Then
      MsgBox "Please enter a number between 1 and 10."
    Else
      MsgBox "Thank you."
      TheForm.Submit   ' Data correct; send to server.
    End If
 Else
    MsgBox "Please enter a numeric value."
 End If
End Sub
-->
</SCRIPT>

To send the data to the server, the code invokes the Submit method on the form object when the data is correct. From there, the server handles the data just as it otherwise would — except that the data is correct before it gets there.

 

Renaming Test Objects

When an object changes in your application, or if you are not satisfied with the current name of a test object for any reason, you can change the name that QuickTest assigns to the stored object. You can also provide objects with meaningful names to assist users in identifying them when using them in component steps.

For example, suppose you have a graphics application in which all the tools in the toolbar are saved as WinObjects in the object repository with the names ToolChild1, ToolChild2, ToolChild3, and so forth. You may want to rename all the buttons to their actual labels to make them easier to identify, for example, Color_Picker, Erasor, Airbrush, and so forth.

You rename objects in the local object repository using the Object Repository window. You rename objects in the shared object repository using the Object Repository Manager.

If you are working with a shared object repository, your change applies to all occurrences of the object in all components that use this shared object repository.

If you are working with a local object repository, your change applies to all occurrences of the object in the selected component. If other components in your business process test also include operations on the local object, you should modify the object's name in each relevant component.

When you modify the name of an object in the local object repository, the name is automatically updated for all occurrences of the object. When you modify the name of an object in a shared repository, the name is automatically updated in all components open on the same computer that use the object repository as soon as you make the change, even if you have not yet saved the object repository with your changes. If you close the object repository without saving your changes, the changes are rolled back in any open components that were open at the time. Changes that are saved are also automatically updated in components that use the object repository as soon as you open them. To see saved changes in a component or object repository that is currently open on a different computer, you must open the object repository or lock it for editing on your computer in order to load the changes.

Tip: If you do not want to automatically update test object names for all occurrences of the test object, you can clear the Automatically update test and component steps when you rename test objects check box in the General tab of the Options dialog box (Tools > Options). If you clear this option, you will need to manually change the test object names in all steps in which they are used, otherwise your component run will fail.

Note: If you rename objects in a shared object repository and save the changes, when you open another component using the same shared object repository, that component updates the object name in all of its relevant steps. This process may take a few moments. If you save the changes to the second component, the renamed steps are saved. However, if you close the second component without saving, then the next time you open the same component, it will again take a few moments to update the object names in its steps.

To rename a test object:

In the object repository tree, select the test object that you want to rename and perform one of the following:

    • Choose Edit > Rename and enter the new name for the object in the selected node in the tree. Then press Enter or click anywhere else to remove the focus from the object.
    • Press F2 and enter the new name for the object.
    • In the Name box in the Object Properties pane, enter the new name for the object. Then click anywhere else to remove the focus from the object.

Note: The name you assign to the object must be unique within the object repository. Object names are not case-sensitive.

 

Updating Test Object Properties

You can update an object in your object repository by selecting the corresponding object in your application and relearning its properties and property values from the application. When you update a test object description in this way, all currently defined properties and values is overwritten, including description properties and values, and ordinal identifier and Smart Identification information. Any object-specific comments that you may have entered are not removed.

This is useful if an object's properties have changed since you added it to the object repository, since QuickTest may not be able to recognize the object unless you update its description.

You can also use this option to update an object that you defined (using the Object > Define New Test Object option) before the application was completely developed, and as a result some of the object properties and values are missing in the test object description, or are no longer sufficient to identify the object. You can do this for objects in the local object repository using the Object Repository window, and for objects in the shared object repository using the Object Repository Manager.

To update test object properties from an object in your application:

  1. In the object repository tree, select the test object whose description you want to update.
  2. Choose Object > Update from Application or click the Update from Application button. QuickTest is minimized and the cursor changes to a pointing hand, so that you can point to and click on any object in the open application.
  3. Find the object in your application whose properties you want to update in the object repository and click it. You must choose an object of the same object class as the test object you selected in the object repository tree.

Notes:

If the object you want to select is in a window that is partially hidden by another window, hold the pointing hand over the partially hidden window for a few seconds. The window comes into the foreground. You can now point and click on the object you want. You can configure the length of time required to bring a window into the foreground in the General tab of the Options dialog box. You can also hold the left Ctrl key to change the window focus. Additionally, if the window containing the object you want to select is minimized, you can display it by holding the left Ctrl key, right-clicking the application in the Windows task bar, and choosing Restore from the context menu.

If the object you want to select can only be displayed by performing an event (such as a right-click or a mouse-over to display a context menu), hold the left Ctrl key. The pointing hand temporarily turns into a standard arrow and you can perform the event. When the object on which you want to spy is displayed, release the left Ctrl key. The arrow becomes a pointing hand again.

If the location you click is associated with more than one object, the Select an Object dialog box opens. Select an object from the object tree and click OK.

The properties and property values for the selected object are updated in the object repository, according to the properties and values required to identify the object that were learned by QuickTest when you clicked the object in your application. Note that all properties and property values in the Test object details area are updated, together with the ordinal identifier and Smart Identification selections. Any object-specific comments that you may have entered are not removed.