Documente Academic
Documente Profesional
Documente Cultură
TABLE OF CONTENTS
2. CREATING A SCRIPT.......................................................................................................................2
4. RECORDING........................................................................................................................................2
5. VERIFICATION POINTS...................................................................................................................2
5.1 TYPES OF VERIFICATION POINTS...................................................................................................3
6. CREATING A WAIT STATE.............................................................................................................4
Rational records in the SQA Basic language; as the name suggests this is a BASIC derived language that is similar
to VB. We should be treating Robot as a programming environment, where we can manually edit scripts, to
include things like conditional statements, loops, custom date types, variables etc. From the libraries in the
SQABAS32 folder we can call sub-routines and functions. We should be looking to put all re-usable code in this
folder.
We can also create datapools which scripts (.rec) files can call from. Datapools are a source of variable test data
that can be used in a script. We can call these through a custom Rational database or from Excel or Access. (We
will deal with creating and using datapools in another document)
1. Creating a script
It will be best to record the scripts through TestManager so we can tie them to requirements or other test inputs.
However if we wish to create a script in Robot we can by just hitting the GUI command button on the toolbar.
As you may well know Robot records the mouse clicks and keystrokes of the user. Try to use keystrokes instead
of mouse clicks and try not to use the scroll-bar as you will find difficulty on playback.
2. Name(s) of Test Scripts
We should name the scripts as much as possible with the names of the requirements that will be input in Test
Manager. So if we a have a requirement that states that ‘Tender Trust must be able to upload a tender’; that script
will be named ‘UploadTenderTrust’ for example. We will talk more about scripting standards at another date.
3.Recording
During recording you will be shown a floatable toolbar that looks like this:
You are able to move this toolbar anywhere within the screen. The movement of the toolbar will not be
recorded in the script. Obviously you will be able to discern what are the pause and stop recording
options. The other two are a little less intuitive.
This button opens the Robot window while recording. I wouldn’t bother about this too much. If I
want to manually enter something in the script while recording the script, I normally pause, then type in
the code.
4. Verification Points
This option you will use more than the stop button. It allows you to create verification points
(VP’s). A verification point is ‘a point in the script that the tester creates in order to confirm the
state of an object across builds of the application under test.’ During recording, a verification point
captures object information (based on the type of verification point) and stores it in a baseline data file.
Rational Robot: A Basic Introduction to Automating Functional Testing
The information in this file becomes the baseline of the expected state of the object during subsequent
builds.
When we play back on a new build, the state of the object is compared against the baselined verification
point. If the captured data does not match the baseline, Robot creates an actual data file. The information
in this file shows that actual state of the object in build.
The results of the verification are now displayed in TestManager in the TestLogViewer. A green flag
shows us that the VP has passed, while a red flag indicates that it has failed. If the VP has failed we can
double-click on the flag and we will be shown where it failed (i.e. there is a comparison of the baselined
data with the actual data.)
The verification toolbar allows you to choose different types of verification points.
Alphanumeric: The alphanumeric test captures and tests alphanumeric data in windows
objects that contain text, such as edit boxes. You can use the VP to verify that text has not
changed, to catch spelling errors and to ensure that numeric values are accurate.
Clipboard: Captures and compares alphanumeric data that has been copied to the clipboard
File Comparison: A file comparison compares two specified files during playback. To insert of
file comparison VP, click Insert > VP > File Comparison. When you create the VP, you specify
the drive, directory and file name(s). You can use the browse facility. During playback, Robot
compares the files byte-for-byte.
File Existence: Verifies the existence of a specified file during playback. Click insert > VP >
File Existence. During playback Robot checks to see if the file exists in the specified location.
Could use for example, to see if registry files have been added.
Menu: The menu VP captures and compares the menu title, menu items, shortcut keys and
the state of selected menus. Robot records information about the top menu and up to five levels of
sub-menus. Robot treats menu items as objects within a menu and tests their content, state, and
accelerator keys regardless of the menu item’s location.
Object Data: Object Data captures and compares the data inside standard Windows objects.
Object Properties: The Object Properties VP captures and compares the properties of
standard Windows objects.
Region and Windows Image comparators - Avoid these like the plague. They are guaranteed to
fail. They capture the screen as a bitmap (pixel by pixel representation) and depending on your
screen resolution, graphics card, colour palette, Operating System ad nauseam. I use window and
region image comparators conditionally:
3
Rational Robot: A Basic Introduction to Automating Functional Testing
If Result = 0 Then
Result = WindowVP (CompareImage, "Caption=TenderTrust - Microsoft Internet Explorer", "VP=Window Image")
End If
For example, if the Tender Trust window does not exist (note the window existence VP), I want
to know what appeared in it’s place, so I capture the image.
We’re in the middle of creating a windows existence VP on the Robot window. Note, that I have named
the verification point so it will give me/us an indication as to what it is doing. And notice the post-fix
‘WE’ (short for windows existence). For Object Properties, put a post-fix ‘OP’, Object Data ‘OD’,
Window Image ‘WI’ etc.
So in this dialog we have ticked the ‘Apply wait state to verification point’ checkbox and this enables the
two edit boxes within the dialog. So in the example above, Robot will search for the existence of its own
window; it will look every two seconds and after thirty seconds will forget all about it. We want the
expected result to equal the actual, hence the radio button chosen.
The code in Robot will look like this:
We can change the wait states, by going into Robot and manually editing the figures in the code.
4
Rational Robot: A Basic Introduction to Automating Functional Testing
3. Working with the Data in Data Grids
When you create a Clipboard, Menu, or Object Data verification point and select an object, you are
actually testing the object's data. This data appears in a Robot data grid, which shows data in rows and
columns. You use the data grid to select and edit the data to test.
In the above example, I have done on Object Data VP on the ‘Find’ utility in Microsoft Outlook. We can
edit this data manually (see below) or we can use any of the following methods to select data in the
columns, rows, or cells of the data grid. If we want a range of contiguous cells click and drag the pointer
over a range of cells. If we want to select non-contiguous cells press the CTRL key and click each cell.
Clicking without the CTRL key cancels previous selections. If you want to select an entire column
click a column title. To test an entire row, click on a row number; Robot compares the data and the
number of items in a row. To test all cells click the box in the upper-left corner of the grid.
To edit data in a grid double-click a cell in the data grid and edit the data in the cell. To accept the
changes, press ENTER. To cancel the changes, press ESC.
5
Rational Robot: A Basic Introduction to Automating Functional Testing
The syntax for this command is: SQALogMessage code%, message$, description
This dialog is displayed by right clicking the message in the log and clicking
properties.
6
Rational Robot: A Basic Introduction to Automating Functional Testing
8.2 SQAGetProperty
Retrieves the value of the specified property.
The syntax for this command is: status% = SQAGetProperty(recMethod$, property$, value)
8.3 SQAWaitForObject
Pauses execution of the script until the specified object can be found.
The syntax for this command is: SQAWaitForObject (recMethod$,timeout&)
7
Rational Robot: A Basic Introduction to Automating Functional Testing
8.5 Callscript
Calls a script from another script and executes it from within the currently-running script.
The syntax is: CallScript script$
Syntax Element Description
script$ Name of the script to be called and executed
8.6 DelayFor
Delays execution of the script for a specified number of milliseconds.The syntax is: DelayFor
TimeInterval&
Syntax Element Description
TimeInterval& Time in milliseconds to delay e.g.
8.7 StartBrowser
Starts an instance of the browser, enables Web testing, and loads a Web page if one is specified.
NOTE:
You must use the StartBrowser command within Robot enables Web object recognition. If you start a
Web browser outside of Robot (that is, without using the StartBrowser command), you must open
rbtstart.htm in your browser, or run the Rational ActiveX Test Control that rbtstart.htm references,
before loading Web pages for testing.
8.8 StartApplication
Starts the specified application from within the currently running script.
The syntax is: StartApplication Pathname$
8
Rational Robot: A Basic Introduction to Automating Functional Testing
5. Compiling a script
When you play back a GUI script, or when you debug a GUI script, Robot compiles the script if it has
been modified since it last ran. You can also compile scripts manually, by pressing this
toolbar button.
Double-click the error or warning in the Build tab, to locate compilation errors in the Script window.
9
Rational Robot: A Basic Introduction to Automating Functional Testing
GO UNTIL CURSOR
Plays back the currently open script, stopping at the text cursor position. It executes until either the
next breakpoint or the end of the script, whichever comes first.
ANIMATE
Plays back the currently open script, displaying a yellow highlighted line
as it executes. It executes until either the next breakpoint or the end of the script, whichever comes
first.
INSERT AT CURSOR
We can continuing recording anywhere in the script by clicking this button. Robot will record at the
cursor position.
When execution stops at a breakpoint, you can examine the value of a variable or check the state of an
object before it is modified by a subsequent command. You can then resume execution until the next
breakpoint or the end of the script.
This puts the caption of Acrobat Reader into the variable ‘value’ (bit of a pointless exercise, because we
already have the caption property), but we can demonstrate that the value of the variable appears in
bottom right hand corner of Robot.
10
Rational Robot: A Basic Introduction to Automating Functional Testing
So the text value will be held in the variable ‘value’ and we could compare it with another value, for
example. The Result is boolean, so if for some reason the text property is not picked up by Robot we will
be returned with a nought ‘0’. The SQA Language Ref is full of Robot internal functions. The manual
comes with TestStudio or it can be accessed on-line.
15.1 SBL/H’s
We cannot automate a project with record and playback. For example if a developer has been given a
requirement to add a dialog box on a PC application and we’ve got 30 scripts that have been recorded
and deal in that area. We’ve got to go into 30 .rec files and copy and paste the code in. What if there
were 100 scripts, a 1000? The time that is wasted could be quite substantial; not only this it is de-
motivating and regression testing is never really done. If however we used the libraries then we could
call a procedure into a .rec file, changing the code only once.
If I can quote from the user guide: ‘Header files have an .SBH extension and contain the procedure
declarations and global variables referred to in your test procedure script files. Source code files have
.SBL extensions and contain the procedure definitions you use in your script files. Header and source
files are stored in *\SQABAS32…’
11
Rational Robot: A Basic Introduction to Automating Functional Testing
15.2 How do I create an SBL?
Go into Robot and choose File > New > SQABasic File. You will be presented with the below
dialog box.
Double click on Library Source file and write your code here:
So for example, the simple function above uses the internal date function, formats it puts it into upper-
case, and stores it in CurrentDate.
Now go into the .SBH file, using the same method: File > New > SQABasic File, but select the Header
File option in the ‘New SQABasic file’ dialog box. Declare the function as below
12
Rational Robot: A Basic Introduction to Automating Functional Testing
We need to reference the header in the .rec file. We do this by using the ‘$Include metacommand.
We can now call the function in a procedure, and we’ve created a msgbox to view the result. And we’ve
got today’s date
13