You are on page 1of 48

Rational Robot

raj.kamal13@gmail.com www.itest.co.nr

Courseware Information
This introductory course is designed to familiarize testing professionals with the basics of Rational's functional test automation tool, Rational Robot. The focus will be on applying Rational Robot to resolve common automated testing challenges and to build effective, versatile test scripts through best practices.

Rational Robot Basics

1. Rational Robot Basics

2. Script Recording

3. Script Playback

4. View logs

DataPool
What is Datapool

Test dataset Supplies data values to the variables in a script during script playback It will automatically pump test data to virtual testers under high-volume conditions

Creation of Datapool
Creating and Populating Datapool

Datapool Creation

Rational Robot

Rational Test Manager

Datapool through Test Manager


Click Tools -> Manage -> Datapools Specify Name Define Datapool fields Assign data type to the datapool columns Specify number of records to generate Click Generate Data

Rational Suite
Suite Contains items such as user or computer groups Resource assigned to each group Test scripts Number of times each test script runs

Rational Suite
Usage of Test Suite

Assign test cases to computers and rerun the test cases without having to reassign them Run test scripts and test cases on the next available computer, thus speeding up testing process Set preconditions on items in a suite, which require that they complete successfully before the next item in the suite runs Group test scripts to emulate the actions of different types of testers Set the order in which test scripts run Synchronize testers

Suite can contain GUI test scripts, VU test scripts, VB test scripts, Java test scripts or other user defined test script types

Creation of Suite
Suite can be created in the following way

Performance Testing Wizard Functional Testing Wizard Existing Session Existing Suite Blank Performance Testing or Functional Testing Suite

Verification Points
Verification Point Point in a script that we create to confirm the state of an object across builds of the application under test.

During Recording, the VP captures object information and stores it in a baseline data file.

While playing back against a new build, Robot retrieves the information in the baseline file for each VP and compares it against the baseline data file.

Verification Point

Types of Verification Points Alphanumeric Clipboard File Comparison File Existence Menu Module Existence Object Data Object Properties Region Image Website Compare Window Existence Window Image Window Scan

Alphanumeric VP
Alphanumeric verification point will be used to capture and test alphabetic or numeric values from a single or multi-line edit box or from other Windows objects that Robot recognizes. You can use the verification point to verify that text has not changed, to catch spelling errors, and to ensure that numeric values are accurate.

Clipboard VP
Clipboard verification point will be used to capture text contained in objects that cannot be captured using any of the other verification points. To use the Clipboard verification point, the application-under-test must supply a Copy or Cut capability so you can place the data in the Clipboard. This verification point is useful for capturing data from spreadsheet and word processing applications as well as terminal emulators. You cannot use it to test bitmaps.

File Verification VP

File Comparison verification point will be to compare two specified files during playback. The comparison is based on the contents of the files and their sizes, not on the file names or dates. When you create the verification point, you specify the drive, directory, and the file names. During playback, Robot compares the files byte-for-byte.

File Existence VP
Use the File Existence verification point to specify a file to look for during playback. When you create the verification point, you specify the drive, directory, and file name for the required file. During playback, Robot checks to see if the file exists in the specified location.

Menu VP
Menu verification point will be used to capture the menu title, menu items, shortcut keys, and the state (enabled, disabled, grayed, or checked) of selected menus. Robot records information about the top menu and as many as 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 items location.

Module Existence VP
Use to verify whether a specified module is loaded into a specified context (process), or is loaded anywhere in memory. In the Windows environment, modules are defined as executable programs (.exe), dynamic link libraries (.dll or other extension), device drivers (.sys or .drv), or display fonts (.fon). Each process has its own context, which includes a set of loaded modules. When you create this verification point, you select the name of the module. You may also select the name of a context (process), in which case the verification point tests whether the module is loaded into that process. If no context is specified, the verification point tests whether the module is loaded anywhere in memory.

Object Data VP
Use the Object Data verification point to capture the data inside objects, including: Standard Window controls ActiveX controls Visual Basic Data controls HTML and Java objects Oracle Forms base-table blocks and items PowerBuilder DataWindows and DataStore controls Menus (you can also use the Menu verification point to test a menu)

Object Properties VP
Use the Object Properties verification point to capture and verify the properties of standard Windows objects. This verification point also provides specialized support for environment-specific objects such as Visual Basic Data controls, ActiveX controls, HTML and Java objects, PowerBuilder DataWindows, and Oracle Forms base-table blocks.

Region Image VP
Use the Region Image verification point to select a region of the screen that Robot captures and saves as a bitmap. The captured region, which can overlap more than one window, is a pixel-by-pixel representation that includes colors, height, and width. For the verification point to pass, the location of the region and the screen resolution should be the same during record and playback.

Window Existence VP
Use the Window Existence verification point to verify the existence and status of a specified window during playback. The status can be normal, minimized, maximized, or hidden. Since the Window Existence verification point does not create a baseline or actual data file, if the verification point fails, you cannot replace baseline data with actual data.

Window Image VP
Use the Window Image verification point to select and capture the client area of a window. The menu, title bar, and border are not included as part of the image capture. Robot can capture any window that is partially or fully visible. The window can be overlapped by another window or partially off the screen. When this occurs, Robot captures the window, but saves the non-visible part of the window as black. The captured region is a pixel-by-pixel representation that includes colors, height, and width. For the verification point to pass, the size of the window and the screen resolution should be the same during record and playback.

Adding Datapool Commands to a GUI Script

Once you finish a recording session in which you provided values to the application, edit the script and perform these basic tasks: Reference the SQAUTIL.SBH header file Substitute variables for the literal values you provided during recording Add datapool commands that open the datapool, fetch a row of data from the datapool, retrieve the individual values in the fetched row, and assign each value to a script variable

Datapool Command - Example


'$Include "sqautil.sbh" Sub Main ... Declare variables with Dim statements ' Open a datapool named CD Orders Dp=SQADatapoolOpen("CD Orders")

' Perform the transaction 100 times, using a new set of data from the datapool each time For x = 1 to 100 ' Fetch a row from the datapool Call SQADatapoolFetch(dp)

Datapool Command Example .


' Begin the transaction 'Credit Card Number Window SetContext, "Caption=Make An Order", "" EditBox Click, "ObjectIndex=3", "Coords=13,11" ' Assign ccNum a value from datapool column #4 Call SQADatapoolValue(dp,4,ccNum) InputKeys ccNum ' Pass the datapool value to the application ... Next x Call SQADatapoolClose(dp) End Sub ' Assign other datapool values to other variables

Extension Manager command

Tools -> Extension Manager Use to select the development environments you need to test. Opens the Extension Manager dialog box. The next time you start Robot, support for the selected environments is loaded. Use to control which Robot extensions are loaded. The Extension Manager lists the special IDE (integrated development environments) environments supported by Robot. Select only the environments you need to test. The next time you start Robot, only the selected environments are loaded. Note: Support for C++ applications is always loaded.

Selecting the IDE Extensions to Load


1. Start Robot. 2. Click Tools - > Extension Manager. 3. Select only the environments that you plan to test. To improve performance, clear the check boxes of all environments you do not plan to test. 4. Exit Robot. The next time you start Robot, only the extensions for the selected environments are loaded.

IDE Extensions - options

Verifiying that the Java Extension Is Loaded To test Java applets and applications, you must first make sure that the Java extension is loaded in Robot. The Java extension includes those additions to Robot that allow Robot to test Java. Verifying that the .NET Extension is Loaded The .NET Extension is loaded by default and is required to recognize Visual Studio.NET Windows Forms controls. To verify that the .NET extension is loaded Note: During installation Robot installs some of our assemblies to global assembly cache. If you install Robot before installing the .NET framework, this step is skipped. In order to test your .NET application, you need to either re-install Robot or copy Dotnetspy.dll and interop.mscoreee.dll into your global assembly cache.

IDE Extensions options ..

Verifying that the HTML Extension Is Loaded To test HTML applications, you must first make sure that an HTML extension is loaded in Robot. Verifying that the Oracle Forms Extension Is Loaded To test Oracle Forms applications, you should first verify that the Robot Oracle Forms extension is loaded in Robot. Verifying that the PowerBuilder Extension Is Loaded To test PowerBuilder applications, you should first verify that the Robot PowerBuilder extension is loaded in Robot. Verifying that the Visual Basic Extension Is Loaded To test Visual Basic applications

Inspector command (Tools menu)


Use to view information about the window, parent, and style of an object, including its window class, ID, and function. Opens the Inspector window. Using the Inspector Use the Inspector to examine window-type objects and display information about those objects, such as class, ID, handle, size, parent data, and style. 1. Click Tools - > Inspector. The tool will automatically begin the object inspection. It will inspect all of the windows objects on your desktop. When it finishes, the Inspector window opens and displays the results. 2. Optionally, click Refresh Object to refresh the inspection of the selected object.

Inspector command (Tools menu)

3. Optionally, click Refresh All to refresh the inspection of all the objects. 4. You can drag the selection hand to any object and release it to inspect that object. The Inspector can assist in general window-type object identification, but it does not have the Object Testing technology of Robot. For example, the Inspector: Does not display object names. Does not detect Visual Basic "soft" controls like labels and shapes. Does not detect any objects inside of PowerBuilder DataWindows.

Functions & Sub Procedures


A Sub procedure does not return a value. A Function procedure returns a value, and can be used in an expression. To specify the data type for the return value of a function, end the Function name with a type declaration character. If no type is provided, the function defaults to data type Variant. Declares a procedure in a module or dynamic link library (DLL) Declare Sub name [ libSpecification ] [ ( arg [ As type ], ... ) ] Declare Function name [ libSpecification ] [ ( arg [ As type ], ... ) ] [ As functype ]

Function Header File

If the libSpecification is of the format: BasicLib "libName" [ Alias "aliasname" ] the procedure is in another SQABasic module (.sbl or .rec) named libName. If the libSpecification is of the format: Lib "libName" [ Alias ["]ordinal["] ] or Lib "libName" [ Alias "aliasname" ] the procedure is in a Dynamic Link Library (DLL) named libName.

Function - Definition

The purpose of a function is to produce and return a single value of as specified type. Recursion is supported. [ Static ] [ Private ] Function name [ ( [ Optional ]arg [ As type ], ... ) ] [ As functype ] name= expression End Function The data type of name determines the type of the return value. If you don't specify a data type, the default data type Variant is used. When calling the function, you need not specify the type declaration character.

Function Definition Contd..

The Static keyword specifies that all the variables declared within the function will retain their values as long as the program is running, regardless of the way the variables are declared. The Private keyword specifies that the function will not be accessible to functions and sub procedures from other modules. Only procedures defined in the same module will have access to a Private function. SQABasic procedures use the call-by-reference convention by default. This means that if the called procedure changes the value of an argument passed in arg, the new value will apply in the calling procedure as well. This feature should be used with great care. Note: Use Sub to define a procedure with no return value.

Function - Arguments
A forward declaration is needed only when function is referenced before it is defined. In this case, the BasicLib, Lib and Alias clauses are not used. Argument is passed to the sub procedure or function. Multiple arguments are separated by commas. The data type of an argument can be specified through a type declaration character or through the As clause. Arguments of a User-Defined data type are declared through an As clause and a type that has previously been defined through the Type statement. If an argument is an array, use empty parentheses after the argument name. The array dimensions are not specified within the Declare statement.

Function Arguments - Contd..

By default, the actual arguments are passed by Far reference. For external DLL procedures, there are two additional keywords, ByVal and Any, that can be used in the argument list. When ByVal is used, it must be specified before the argument it modifies. When applied to numeric data types, ByVal indicates that the argument is passed by value, not by reference. When applied to string arguments, ByVal indicates that the string is passed by Far pointer to the string data. By default, strings are passed by Far pointer to a string descriptor. Any can be used as a type specification, and permits a call to the procedure to pass a value of any data type

Function Terminate \ Exit


Terminates Loop statements or transfers control to a calling procedure. Exit {Do | For| Function | Sub} Use Exit Do inside a Do...Loop statement. Use Exit For inside a For...Next statement. When the Exit statement is executed, control transfers to the statement after the Loop or Next statement. When used within a nested loop, an Exit statement moves control out of the immediately enclosing loop. Use Exit Function inside a Function...End Function procedure. Use Exit Sub inside a

SQABasic Library
SQABasic library files let you declare custom procedures that you can call from a script file or other library file. Declare Sub MySub BasicLib "MyLib" (arg1 As String, arg2 As Integer) The word BasicLib is added to the declaration, indicating that the declared procedure MySub is in an SQABasic library file. The name of the library file (MyLib), in quote marks, follows the BasicLib designation. The library file extension (.sbl or .rec) is not required.

SQABasic Library Contd..

Note that the BasicLib keyword specifies that a .sbx library file (as opposed to a .dll library file) is being declared. The .sbx extension in the declaration is not required or recommended. Where to Declare an SQABasic Library File You can declare an SQABasic library file in any of these locations: In a script or other library file, for use by the procedures in that module only In a header file, for use by any module that references the header file

SQABasic Library - Types

You can create and edit these types of SQABasic library files: .sbl libraries : If a .sbl file is in the SQABasic path, it can be accessed from a file in the current project or in other projects. .sbl library files to not support verification points. .rec libraries.: A script file used as a library file can only be accessed by files in the same project. .rec library files support verification points. Note: For your convenience, Robot provides a blank library source file, called global.sbl, in each project. You can add your custom procedures to this file and/or create new library source files.

SQABasic Library - Compile

Compile the SQABasic library file before you attempt to access it at test runtime. Compiling SQABasic library files is the same for both .sbl files and .rec files. Compiling the file also saves it. Compiled .sbl and .rec library files have the extension .sbx. When you compile a .sbl file, the .sbx file is stored in the SQABasic path This is true even if the .sbl file is not in the SQABasic path.

DLL Library Files

SQABasic procedures can call procedures stored in DLL files. For example, they can call the procedures stored in Microsoft Windows DLLs such as Kernel32.dll. Robot does not provide a tool for creating DLLs. To add procedures to a DLL file, you need a tool such as Microsoft Visual C++ or Visual Basic. Declare Sub MySub Lib "MyDLL" (ByVal arg1 As String, ByVal arg2 As Integer) Declare a DLL File in a script or SQABasic library file, for use by the procedures in that module only or in a header file, for use by any module that references the header file

Libraries - Comparision
The following table summarizes the differences between library files: .sbl Location SQABasic path .rec .dll

Datastore (folder TMS_Scripts\dll folder, TMS_Scripts) in the or a user assigned current project location Depends on location

Scope

When in the SQABasic Available to files in path, available to files the same project in the same project or other projects No Support

VP

Support all standard Supports Custom VP robot VP

SQABasic Header Files

Types of SQABasic Header Files Header files, stored in the SQABasic path. When a header file is in the SQABasic path, it is available to all modules in the same project and in other projects. Project header files, stored in the TMS_Scripts folder of the project. Project header files are available to all modules in the same project. Both types of SQABasic header files have the extension .sbh.

SQABasic Header Files - Creation

Creating a Header File To create a header file in the current SQABasic path: 1. In Robot, click File - > New - > SQABasic File. 2. Click Header File, and then click OK. Save the file in the default location. You name the file (or accept the default name) the first time you save it.

SQABasic Header Files - Use

Includes statements from the specified header or source file. '$Include: "filename" It is recommended (although not required) that you specify a file extension of .SBH if filename is a header file. SQABasic header files can be accessed by modules within the current project or within any other project. Typically, the '$Include meta command is located before the beginning of the sub procedure.

Questions

You might also like