Using the API to edit functional test scripts
These topics describe how
you can take advantage of the Rational® Functional Tester application programming
interface (API) or the scripting framework to make changes to functional
test scripts. As a general rule, the modifications that you make with
the scripting SDK, should emulate as closely as possible, the user
interactions to test with the application-under-test.
You can start by using the scripting framework to make some of these simple modifications to recorded functional test scripts:
- Change a user action, such as object().drag() to object().click().
- Delete recorded commands.
- Place an often repeated sequence of actions into a method.
- Writing messages to the log
A log is a file that contains the record of events that occur while a Functional Test script is playing back. There are several different methods you can use to write messages to the log. - Modifying options for script execution
Some scripting framework options that affect script execution can be specified through the user interface. Values that you set in the user interface persist as the default values from script to script. However, you can also use the scripting framework to set some of these options directly in the functional test script, for example, the amount of time between keystrokes. - Starting a test script from within a script
Test scripts can contain methods that invoke other test scripts. You might want to take advantage of this functionality by creating a test script that serves as a command file for a suite of scripts. - Querying values of object properties
Components in the application-under-test, such as dialog boxes, command buttons, and labels, have associated pieces of information called properties. Properties have a name and a value. This topic provides examples of why you may want to modify your script to access an object property. - Unregistering references to test objects
Helper script methods refer to an object in the application-under-test by using the test object map. Rational Functional Tester finds such mapped objects each time a method is called on the object. In some cases; however, you might not want Rational Functional Tester to do this. - Handling ambiguous recognition
In some situations during playback, Rational Functional Tester might not be able to differentiate between two similar objects in the software that is being tested. This topic describes handling these situations. - Adding manual and dynamic verification points
In addition to verification points specified during recording, you can also incorporate new verification points into a Functional Test script. Scripting manual and dynamic verification points enables you to specify data for comparison against an object that is not found in the test object map. The data, however, must be value-class based. - Handling unexpected active Windows
A common problem in GUI testing is the appearance of an unexpected active window -- for example, a warning message box in an HTML browser. This topic describes how to handle this problem. - Rational Functional Tester examples
Rational Functional Tester ships with some example code you can use in your own scripts. You can open these examples from within the sample project shipped with Rational Functional Tester. - Determining the values of cells in a table
When working with Java™ or HTML tables, you might want to extract the value of a given cell in the table. There are many ways to do this; one simple approach is to query the table directly. - Reading the Windows registry
The Windows registry is a database used by the Windows operating system to store configuration information. Often it becomes necessary for a tester to read information out of this database using Rational Functional Tester commands. This topic provides examples for doing this. - Iterating through items in a tree control using the getTestData method
This topic provides an example of using Rational Functional Tester's getTestData method to programmatically access the values on the branches of a tree control. - Iterating through table cells using the getTestData method
This topic provides an example of using Rational Functional Tester's getTestData method to access the values in the cells of a grid control. - Passing parameters to the callScript method
This topic describes how to use the different signatures of the callScript method to pass data from one script to another. - Extracting data from a combobox/list control (JComboBox)
You can use Rational Functional Tester's getTestData method to access the values in the list of a ComboBox/List control. - Playing back low level mouse and keyboard actions
Low-level playback of mouse and keyboard actions provides more control of events of user actions. For example, Rational Functional Tester currently supports TestObject.click(), where the click consists of low-level actions including mouse move, left mouse button down, and left mouse button up. With this functionality, you can play back the individual components of a mouse click. - Searching for test objects
You can search for one or more test objects that match specified search criteria. The search is based on name/value pairs that represent properties of the test object or test objects you are looking for. The search can either be global, or limited to children of a parent test object. - Searching for SAP TestObjects
With Rational Functional Tester, you can locate one or more SAP TestObjects matching a specified search criteria, even without using the Object Map. - Tracing AJAX requests
You can test AJAX-based applications in two different ways; by setting the Auto Trace option to true or by setting the Auto Trace option to false on the corresponding document object. By setting Auto Trace option to true, you can trace the AJAX requests. - Searching for GEF objects
Rational Functional Tester recognizes the GEF EditParts and Palettes. Some Figures may not have an association with an EditPart. You can use Rational Functional Tester APIs to find such Figures as shown in the below examples. - Passing parameters by using the describe function in PowerBuilder
In PowerBuilder, you can use the describe() function to identify the properties of DataWindow objects and their controls. The describe() function is available only with the PowerBuilder DataWindow. The describe() function returns a string as a result of the parameters that are specified as a part of the describe() function. For example, you can find the data types of the column in a table style presentation. You can use the describe function in Rational Functional Tester as shown in the following examples. - Finding the state of the browser
When you record functional test scripts, if you find that some controls were not picked up by the recording, you can verify whether the browser used during the recording was in a ready state for recording. Similarly, if you encountered problems during playback, you can verify the state of the browser. You can use the dynamic find() API and use the Html.HtmlBrowser method for this purpose. - Finding objects in a Dojo tree
You can use the dynamic find() API and the dojoTreeExpand() method to find all objects within a Dojo tree control within the application under test. - Reading multiple datapools from a functional test script
You can use the dynamic find() API to read multiple datapools from a functional test script. - Selecting an item from a Java drop-down list
You can modify the dynamic find() API to use the mapped and dynamic test objects, to select an item from a drop-down list in a Java application, as the following example illustrates: - Verifying the status of a radio button or check box
You can use the dynamic find() API to verify the status of a radio button or check box during playback, such as whether the control was selected or not. - Closing active browsers before playback
You can use the dynamic find() API to find and close all active browsers before you play back a script to ensure that there are no active browser instances before playback. - Closing unexpected HTML dialog boxes during playback
You can use the dynamic find() API to close HTML dialog boxes that are displayed unexpectedly during playback, to ensure smooth playback. - Writing messages to the log
A log is a file that contains the record of events that occur while a Functional Test script is playing back. There are several different methods you can use to write messages to the log. - Modifying options for script execution
Some scripting framework options that affect script execution can be specified through the user interface. Values that you set in the user interface persist as the default values from script to script. However, you can also use the scripting framework to set some of these options directly in the functional test script, for example, the amount of time between keystrokes. - Starting a test script from within a script
Test scripts can contain methods that invoke other test scripts. You might want to take advantage of this functionality by creating a test script that serves as a command file for a suite of scripts. - Querying values of object properties
Components in the application-under-test, such as dialog boxes, command buttons, and labels, have associated pieces of information called properties. Properties have a name and a value. This topic provides examples of why you may want to modify your script to access an object property. - Unregistering references to test objects
Helper script methods refer to an object in the application-under-test by using the test object map. Rational Functional Tester finds such mapped objects each time a method is called on the object. In some cases; however, you might not want Rational Functional Tester to do this. - Handling ambiguous recognition
In some situations during playback, Rational Functional Tester might not be able to differentiate between two similar objects in the software that is being tested. This topic describes handling these situations. - Adding manual and dynamic verification points
In addition to verification points specified during recording, you can also incorporate new verification points into a Functional Test script. Scripting manual and dynamic verification points enables you to specify data for comparison against an object that is not found in the test object map. The data, however, must be value-class based. - Handling unexpected active Windows
A common problem in GUI testing is the appearance of an unexpected active window -- for example, a warning message box in an HTML browser. This topic describes how to handle this problem. - Rational Functional Tester examples
Rational Functional Tester ships with some example code you can use in your own scripts. You can open these examples from within the sample project shipped with Rational Functional Tester. - Determining the values of cells in a table
When working with Java or HTML tables, you might want to extract the value of a given cell in the table. There are many ways to do this; one simple approach is to query the table directly. - Reading the Windows registry
The Windows registry is a database used by the Windows operating system to store configuration information. Often it becomes necessary for a tester to read information out of this database using Rational Functional Tester commands. This topic provides examples for doing this. - Iterating through items in a tree control using the getTestData method
This topic provides an example of using Rational Functional Tester's getTestData method to programmatically access the values on the branches of a tree control. - Iterating through table cells using the getTestData method
This topic provides an example of using Rational Functional Tester's getTestData method to access the values in the cells of a grid control. - Passing parameters to the callScript method
This topic describes how to use the different signatures of the callScript method to pass data from one script to another. - Extracting data from a combobox/list control (JComboBox)
You can use Rational Functional Tester's getTestData method to access the values in the list of a ComboBox/List control. - Playing back low level mouse and keyboard actions
Low-level playback of mouse and keyboard actions provides more control of events of user actions. For example, Rational Functional Tester currently supports TestObject.click(), where the click consists of low-level actions including mouse move, left mouse button down, and left mouse button up. With this functionality, you can play back the individual components of a mouse click. - Searching for test objects
You can search for one or more test objects that match specified search criteria. The search is based on name/value pairs that represent properties of the test object or test objects you are looking for. The search can either be global, or limited to children of a parent test object. - Searching for SAP TestObjects
With Rational Functional Tester, you can locate one or more SAP TestObjects matching a specified search criteria, even without using the Object Map. - Tracing AJAX requests
You can test AJAX-based applications in two different ways; by setting the Auto Trace option to true or by setting the Auto Trace option to false on the corresponding document object. By setting Auto Trace option to true, you can trace the AJAX requests. - Searching for GEF objects
Rational Functional Tester recognizes the GEF EditParts and Palettes. Some Figures may not have an association with an EditPart. You can use Rational Functional Tester APIs to find such Figures as shown in the below examples. - Passing parameters by using the describe function in PowerBuilder
In PowerBuilder, you can use the describe() function to identify the properties of DataWindow objects and their controls. The describe() function is available only with the PowerBuilder DataWindow. The describe() function returns a string as a result of the parameters that are specified as a part of the describe() function. For example, you can find the data types of the column in a table style presentation. You can use the describe function in Rational Functional Tester as shown in the following examples. - Finding the state of the browser
When you record functional test scripts, if you find that some controls were not picked up by the recording, you can verify whether the browser used during the recording was in a ready state for recording. Similarly, if you encountered problems during playback, you can verify the state of the browser. You can use the dynamic find() API and use the Html.HtmlBrowser method for this purpose. - Finding objects in a Dojo tree
You can use the dynamic find() API and the dojoTreeExpand() method to find all objects within a Dojo tree control within the application under test. - Reading multiple datapools from a functional test script
You can use the dynamic find() API to read multiple datapools from a functional test script. - Selecting an item from a Java drop-down list
You can modify the dynamic find() API to use the mapped and dynamic test objects, to select an item from a drop-down list in a Java application, as the following example illustrates: - Verifying the status of a radio button or check box
You can use the dynamic find() API to verify the status of a radio button or check box during playback, such as whether the control was selected or not. - Closing active browsers before playback
You can use the dynamic find() API to find and close all active browsers before you play back a script to ensure that there are no active browser instances before playback. - Closing unexpected HTML dialog boxes during playback
You can use the dynamic find() API to close HTML dialog boxes that are displayed unexpectedly during playback, to ensure smooth playback.
Feedback