Top Banner
Advanced Rational Robot [email protected] www.itest.co.nr
57

Advanced Rational Robot A Tribute ()

Jan 14, 2015

Download

Technology

raj.kamal13

Rational Robot, Automation, Test automation, Software Testing
http://www.geektester.blogspot.com
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 2: Advanced Rational Robot   A Tribute ()

Courseware Information

•This advanced course is designed to familiarize testing professionals with concept which are not used on daily basis but can be very handy in various situations.

•The focus will be on applying Rational Robot to resolve complex automated testing challenges and to build effective, versatile test scripts through best practices.

Page 3: Advanced Rational Robot   A Tribute ()

Rational Robot Basics

4.View logs

2.Script

Recording

3.Script

Playback

1.Rational Robot

Basics

Page 4: Advanced Rational Robot   A Tribute ()

Types of SQABasic Header Files

SQABasic supports two types of 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.

Note: Both types of SQABasic header files have the extension .sbh.

Page 5: Advanced Rational Robot   A Tribute ()

SQABasic Path

The SQABasic path is where Robot saves and looks for .sbl library files and header files.

The SQABasic path is user definable in Robot.

Once you explicitly define the SQABasic path in Robot, the path is persistent.

Robot automatically sets the SQABasic path when all of the following conditions are true:

You have not yet explicitly defined an SQABasic path in Robot.

You have created a new project and datastore in Rational Administrator.

You open Robot using the newly created project and datastore.

Page 6: Advanced Rational Robot   A Tribute ()

Absolute or Relative Path

Optionally, you can use an absolute or relative path to reference header files and project header files.

For example, if you want a script to reference the header file MyHeader.sbh, regardless of the current SQABasic path, and the script and header file are in the default locations of the same project, you can use the following declaration:

'$Include "SQABas32\MyHeader.sbh"

Page 7: Advanced Rational Robot   A Tribute ()

Creating an SQABasic Header File

Project-wide header files can be referenced by any file in the project.

Creating a Header File

To create a new header file that can be accessed by any module in the project:

Click File -> New -> SQABasic File.

Click Header File, and then click OK.

Page 8: Advanced Rational Robot   A Tribute ()

Creating an Project Header file

Use to create a new project header file (file extension .sbh).

SQABasic header files you create with this command have project-wide scope and are stored in the Script folder of the project.

Project header files can be referenced by any file in the project.

To create a new project header file:

Click File -> New -> Project Header File.

You name the file (or accept the default name) the first time you save it.

Page 9: Advanced Rational Robot   A Tribute ()

Metacommand

'$CStrings : Tells the compiler to treat a backslash character (\) inside a string as an escape character.

SYNTAX: '$CStrings [ Save | Restore ]

The supported special characters are:\n Newline (Linefeed)\t Horizontal Tab\b Backspace\\ Backslash\' Single Quote\" Double Quote

Page 10: Advanced Rational Robot   A Tribute ()

Escape Sequence - exampleSub main

'$CStrings

MsgBox "This is line 1\n This is line 2 (using C Strings)"

'$NoCStrings

MsgBox "This is line 1" +Chr$(13)+Chr$(10)+"This is line 2 (using Chr)"

End Sub

Page 11: Advanced Rational Robot   A Tribute ()

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

Page 12: Advanced Rational Robot   A Tribute ()

Steps to use DLL Functions

Steps:

1. Create a Active X DLL Project

2. Define Functions / Sub Procedures

3. Save Class & Project

<Proj Name>:\TestDatastore\DefaultTestScriptDatastore\TMS_Scripts\dll)

4. Create a DLL & Register it.

5. Create a Header File

6. Declare the Function or Sub procedure (from DLL)

7. Create GUI Script

8. Call Function or Sub Procedure

Page 13: Advanced Rational Robot   A Tribute ()

Steps .. In detail

Step 1: Create a Visual Basic – “Active X dll Project”

Step 2:Public Function temp() As String

temp = “At last its working"End Function

Step 3: Save Project & Class

Project: Prj.vbpClass: temp.cls

Step 4 (a): Create a DLL < temp.dll >

Page 14: Advanced Rational Robot   A Tribute ()

Steps .. In detail

Step 4(b): Registering a DLL

RegSvr32 “<DLL Path>\temp.dll>

Step 5 & 6 : Create a Header File (Rational Robot)

Declare Function temp Lib "temp.dll" ()

Step 7 & 8 : Create a GUI Script and Call DLL function

'$include “temp.sbh"

Dim x as Object

Set x = CreateObject(“prj.temp")

MsgBox x.temp

Page 15: Advanced Rational Robot   A Tribute ()

Libraries - Comparision

The following table summarizes the differences between library files:

.sbl .rec .dll

Location SQABasic path Datastore (folder TMS_Scripts) in the current project

TMS_Scripts\dll folder, or a user assigned location

Scope When in the SQABasic path, available to files in the same project or other projects

Available to files in the same project

Depends on location

VP No Support Support all standard robot VP

Supports Custom VP

Page 16: Advanced Rational Robot   A Tribute ()

Argument Type - ByVal

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.

Page 17: Advanced Rational Robot   A Tribute ()

Argument Type - Any

Any can be used as a type specification, and permits a call to the procedure to pass a value of any data type.

When Any is used, type checking on the actual argument used in calls to the procedure is disabled (although other arguments not declared as type Any are fully type-safe).

Page 18: Advanced Rational Robot   A Tribute ()

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.

Page 19: Advanced Rational Robot   A Tribute ()

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.

Page 20: Advanced Rational Robot   A Tribute ()

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.

Page 21: Advanced Rational Robot   A Tribute ()

Recording Modes

Object-Oriented Recording – Examines objects in the AUT at the Windows layer during recording and playback. Robot uses internal object names to identify objects. If objects in your application's graphical user interface (GUI) change locations, your tests still pass because the scripts are not location dependent.

Low-level recording – Tracks detailed mouse movements and keyboard actions by screen coordinates and exact timing. Use low-level recording when you are testing functionality that requires the tracking of detailed mouse actions, such as in painting, drawing, or CAD applications.

Page 22: Advanced Rational Robot   A Tribute ()

Low Level Recording

When you click Record -> Turn Low-Level Recording On or Press CTRL+SHIFT+R during recording, subsequent mouse and keyboard actions are automatically stored in an external file.

Robot inserts the PlayJrnl command into the script to reference the external low-level file.

Low-level scripts are listed in the Robot Asset pane.

To display the contents of a low-level file, double-click the file's ID.

To return to Object-Oriented Recording, click Record -> Turn Low-Level Recording Off or Press CTRL+SHIFT+R.

Page 23: Advanced Rational Robot   A Tribute ()

Playing back Low-Level Scripts

During playback, the PlayJrnl command invokes the low-level file. This file plays back all recorded actions in real time, exactly as recorded. This differs from Object-Oriented Recording, which examines Windows objects in the application-under-test, and does not depend on precise timing or screen coordinates.

When you switch to low-level recording, Robot does the following:

Records low-level actions in a binary script file that cannot be edited.

Gives the low-level script file the next consecutive number, and displays the number in the Asset (left) pane.

Adds a PlayJrnl command to your script that references the low-level script file.

Page 24: Advanced Rational Robot   A Tribute ()

PlayJrnl Utility Command

Starts playback of a series of low-level recorded mouse and keyboard actions.

Syntax:

PlayJrnl scriptID

scriptID: A unique number that Robot assigns to the low-level script file.

Example: PlayJrnl "001"

Page 25: Advanced Rational Robot   A Tribute ()

Clipboard Verification Point

Use the Clipboard verification point 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.

Page 26: Advanced Rational Robot   A Tribute ()

Clipboard Commands

The Windows Clipboard can be accessed directly in your program to enable you to get text from and put text into other applications that support the Clipboard.

SYNTAX

Clipboard.Clear

Clipboard.GetText()

Clipboard.SetText string$

string$: A string or string expression containing the text to send to the Clipboard. Used with the .SetText method.

Page 27: Advanced Rational Robot   A Tribute ()

SQAShellExecute Utility Command

If filename references an application, SQAShellExecute runs the application.

If filename references a file other than an application executable, SQAShellExecute opens the file through the application that has a Windows association with the file type. (Windows maintains associations between an application and its file types by associating the application with a particular file extension.) For example, suppose Microsoft Word has a Windows association with .DOC files. If filename references MEMO.DOC, SQAShellExecute runs Word and opens MEMO.DOC in the Word environment.

Example: SQAShellExecute “C:\Winnt\System32\Notepad.Exe”,””,””

Page 28: Advanced Rational Robot   A Tribute ()

SQASetProperty Command

Assigns a value to a specified property.

status% = SQASetProperty(recMethod$, property$, value)

Example: SQASetProperty "Name=FirstName", "Text", "Michael“

Page 29: Advanced Rational Robot   A Tribute ()

SQAGetPropertyNames

Retrieves an array containing the names of all the object's properties.

status% = SQAGetPropertyNames(recMethod$, aPropNames())

Example:Dim a() as String

Window SetContext, "Caption=Advanced.txt - Notepad", ""x = SQAGEtPropertyNames("Type=EditBox;ObjectIndex=1",a)For i = LBound(a) to UBound(a) MsgBox a(i) Next i

Page 30: Advanced Rational Robot   A Tribute ()

SQAGetPropertyArray Command

Retrieves an array of values for the specified property.

status% = SQAGetPropertyArray(recMethod$, property$, aPropValues())

Example: Dim a() as variant Window SetContext, "Caption=Font", ""

x = SQAGetPropertyArray("Type=ComboListBox;Label=Font style:","List",a) For i = Lbound(a) to Ubound(a) MsgBox a(i)

Next i

Page 31: Advanced Rational Robot   A Tribute ()

GUI Playback Options - Trap tabTool -> GUI Playback Options -> Trap

Use to specify what information the Trap utility captures about general protection faults that occur during playback and the recovery method to use.

Page 32: Advanced Rational Robot   A Tribute ()

GUI Playback Options - Trap tab

To include the contents of the stack for non-current tasks, select Stack trace.

To include the module and class list information, select Module and class list.

Click one of the following to specify what Trap should do after detecting a GPF:Restart windows session – Trap restarts Windows.

Call user-defined sub procedure – Trap calls the sub-procedure in the module that you specify. Select this option to specify your own custom SQABasic error handling. Type the names of the library source file (with an .sbl extension) and the sub-procedure.

Page 33: Advanced Rational Robot   A Tribute ()

SQATrap Log fileThe Sqatrap.log file can contain a variety of information about failure events. The following failure information is always written to Sqatrap.log:

Contents of the stack for the current taskNames of functions that were called just before the error occurredContents of CPU registersDate/Time stamp and Fault Number

After every trapped event, Trap appends error data to the existing Sqatrap.log file in the Rational Test installation directory, or creates a new file if one does not exist.

A trapped event’s entry in the file begins with line:<!SQA: ROBOT - start Log File for current UAE/Fault!>

End of LOG File for given UAE/Fault<!STOP!>

Page 34: Advanced Rational Robot   A Tribute ()

Trap

Robot uses the Trap utility to detect the occurrence of General Protection Faults (GPF) and the location of the offending function call. If a GPF is detected, Robot updates a log file that provides information about the state of the Windows session that was running.

The occurrence of a GPF usually results in a crash of the running application and may also result in a loss of data.

Capture information about GPFs.

Write the state of your environment to a log file when a GPF is detected.

Specify the type of information to write to the log file.

Automatically restart Windows or call your own error handling sub-procedure before performing any other action.

Page 35: Advanced Rational Robot   A Tribute ()

Trap – Contd..

Trap detects and traps the following events:

UAE: General Protection Fault #13

Stack Overflow: Fault #12

Invalid Op Code: Fault #6

Divide by Zero: Fault #0

Page 36: Advanced Rational Robot   A Tribute ()

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.

Page 37: Advanced Rational Robot   A Tribute ()

Module Existence VPClick Insert -> Verification Point -> Module Existence.

Page 38: Advanced Rational Robot   A Tribute ()

Object Data Test Definition

Use to set the options for a data test.

What do you want to do?

Create or edit a custom data test

Create or edit the expression in a custom data test

Rename a custom data test

Copy a data test

Delete a custom data test

Page 39: Advanced Rational Robot   A Tribute ()

Object Data Test Definition

Page 40: Advanced Rational Robot   A Tribute ()

Object ListUse to select an object to test from the Windows desktop while

creating a verification point.

Show hidden Invert object

Page 41: Advanced Rational Robot   A Tribute ()

Object List

Show Hidden: Shows all objects on the Windows desktop.

Objects with a Visible property of False. Examples are hidden Visual Basic Data controls and PowerBuilder DataWindows.

Objects with no GUI component. Examples are PowerBuilder DataStore controls and Oracle Forms blocks.

Invert Object:

When you select an object in the list, inverts the object's colors in the application window if the object is visible.

Page 42: Advanced Rational Robot   A Tribute ()

Skip VP & Acknowledge Results

Select Acknowledge results to have Robot display a pass/fail result message for each verification point. You must click OK before playback continues. If selected, Robot skips verification points during playback. You may want to skip verification points for debugging during the test development phase, but not for actual testing.

Page 43: Advanced Rational Robot   A Tribute ()

Unexpected Active Window

Use to specify how Robot responds to the appearance of an unexpected active window during playback.

An unexpected active window is any window that is not expected by Robot during playback and that prevents the expected window from being made active.

Page 44: Advanced Rational Robot   A Tribute ()

GUI Record OptionsType the default prefix for every new GUI script that you record. Each time you record a new GUI script, the prefix is appended with a consecutive number.

Records a mouse drag as a mouse click within a push button, option button, check box, and label while

recording. This prevents inadvertent mouse drags from being written in the script as drags.

Page 45: Advanced Rational Robot   A Tribute ()

Manage Queries Dialog Box

Use this dialog box to manage script or session queries.

To open: Click Tools -> Manage Script Queries .Click the New or Edit button in the Manage Queries dialog box.

Page 46: Advanced Rational Robot   A Tribute ()

Manager Queries Dialog Box

Page 47: Advanced Rational Robot   A Tribute ()

Begin Dialog .. End Dialog

Begins and ends a dialog-box declaration.

Begin Dialog dialogName [x , y ,] dx , dy [, caption$ ]

... ' dialog box definition statements

End Dialog

ButtonGroup Statement:

Begins the definition of a group of custom buttons for a dialog box.

ButtonGroup .field

Page 48: Advanced Rational Robot   A Tribute ()

Begin Dialog .. End Dialog

Begin Dialog UserDialog 274, 171, "SQABasic Dialog Box"ButtonGroup .ButtonGroup1Text 9, 3, 69, 13, "Filename:", .Text1

TextBox 9, 3, 69, 13, .Text3DropComboBox 9, 14, 81, 119, ComboBox1(), .ComboBox1Text 106, 2, 34, 9, "Directory:", .Text2ListBox 106, 12, 83, 39, ListBox1(), .ListBox2

Text 106, 52, 42, 8, "Drive:", .Text3 DropListBox 106, 64, 95, 44, DropListBox1(), .DropListBox1

CheckBox 9, 142, 62, 14, "List .TXT files", .CheckBox1 GroupBox 106, 111, 97, 57, "File Range"

OKButton 213, 6, 54, 14 CancelButton 214, 26, 54, 14 PushButton 213, 52, 54, 14, "Help", .Push1 End Dialog

Dim mydialog as UserDialog On Error Resume Next Dialog mydialog If Err=102 then MsgBox "Dialog box canceled." End If

Page 49: Advanced Rational Robot   A Tribute ()

CreateObject Function

Creates a new OLE2 automation object.

SYNTAX: CreateObject( class )

class: The name of the application, a period, and the name of the object to be used.

To create an object, you first must declare an object variable, using Dim, and then Set the variable equal to the new object, as follows:

Dim OLE2 As Object

Set OLE2 = CreateObject(“Excel.Application")

Page 50: Advanced Rational Robot   A Tribute ()

New Operator

Allocates and initializes a new OLE2 object of the named class.

SYNTAX

Set objectVar = New className (or)

Dim objectVar As New className

objectVar: The OLE2 object to allocate and initialize.

className: The class to assign to the object.

In the Dim statement, New marks objectVar so that a new object will be allocated and initialized when objectVar is first used. If objectVar is not referenced, then no new object will be allocated.

Page 51: Advanced Rational Robot   A Tribute ()

Dynamic Data Exchange

Dynamic Data Exchange (DDE) is a process by which two applications communicate and exchange data. One application can be an SQABasic script.

Here's a high-level overview of a DDE exchange. Click a topic for more information:

Open a DDE channel

Communicate with the application

Close the channel

Page 52: Advanced Rational Robot   A Tribute ()

DDE – Open a Channel

To "talk" to another application and send it data, open a connection (called a DDE channel) using the statement DDEInitiate.

DDEInitiate requires two arguments:

The DDE application name. For example, the DDE name for Microsoft Word is WINWORD.

The topic name. This name is usually a open filename. Many applications that support DDE recognize a topic named System, which is always available and can be used to find out which other topics are available.

Note: The application must already be running before you can open a DDE channel. To start an application, use the Shell command.

Page 53: Advanced Rational Robot   A Tribute ()

DDE – Communicate with the App

After you open a channel to an application, you can get text and numbers (DDERequest), send text and numbers (DDEPoke), or send commands (DDEExecute). See the application's documentation for a list of supported DDE commands.

To make sure the application performs a DDE task as expected, use DDEAppReturnCode. If an error does occur, your program can notify the user.

Systems: A list of all items in the System topic

Topics: A list of available topics

Formats: A list of all the Clipboard formats supported

Page 54: Advanced Rational Robot   A Tribute ()

DDE – Close the channel

When you're finished communicating with the application, you should close the DDE channel using DDETerminate. Because you have a limited number of channels available at once (depending on the operating system in use and the amount of memory you have available), it's a good idea to close a channel as soon as you finish using it.

Page 55: Advanced Rational Robot   A Tribute ()

Dynamic Data Exchange

DDEAppReturnCode: Return a code from an application on a DDE channel.

DDEExecute: Send commands to an application on a DDE channel.

DDEInitiate: Open a dynamic data exchange (DDE) channel.

DDEPoke: Send data to an application on a DDE channel.

DDERequest: Return data from an application on a DDE channel.

DDETerminate: Close a DDE channel.

Page 56: Advanced Rational Robot   A Tribute ()

DDE Example

appname="WinWord" path="D:\Program Files\Microsoft Office\Office\" topic="System" item="Page1" testtext="Hello, world." On Error Goto Errhandler x=Shell(path & appname & ".EXE") channel = DDEInitiate(appname, topic) If channel=0 then MsgBox "Unable to open Word." Exit Sub End If

DDEPoke channel, item, testtext

pcommand="[FileSaveAs .Name = " & Chr$(34) & "C:\xxx.doc" & Chr$(34) & "]" DDEExecute channel, pcommand pcommand="[FileClose]" DDEExecute channel, pcommand

DDETerminate channel

Page 57: Advanced Rational Robot   A Tribute ()

Questions