ibm rational software development conference … rational software development conference 2006 ......
TRANSCRIPT
IBM Rational SoftwareDevelopment Conference 2006
SQ14© 2006 IBM Corporation
®
IBM(R) Rational(R) Robot Tips andTechniques
Prathiba Rangappa, Kamala ParvathanathanIBM Rational IBM [email protected] [email protected]
IBM Rational Software Development Conference 2006
SQ142
Agenda
Beginner level
Intermediate level
Advanced level
IBM Rational Software Development Conference 2006
SQ143
Tip 1: Stopping Playback – Rational Robot You can stop playback any time you needYou can stop playback any time you need
F11 key stops playback at any timeF11 key stops playback at any time
Registry SettingRegistry SettingHKEY_CURRENT_USERHKEY_CURRENT_USER\\SoftwareSoftware\\Rational SoftwareRational Software\\
RationalRational TestTest\\88\\RobotRobot\\PlaybackPlayback
Add Add HotkeyStopHotkeyStopUse DWORD type and decimal values in slide notesUse DWORD type and decimal values in slide notes
IBM Rational Software Development Conference 2006
SQ144
Tip 2: Pausing Playback – Rational Robot You can pause playback any time you need
F12 key pauses playback at any time
Registry Setting
HKEY_CURRENT_USER\Software\Rational Software\
Rational Test\8\Playback
Add HotkeyPause
Use DWORD type and decimal values in slide notes
IBM Rational Software Development Conference 2006
SQ145
Tip 3: Escape The Insanity!
Press ESC to stop object properties capture
Select individual items
ESCESCESC
IBM Rational Software Development Conference 2006
SQ146
Tip 4: Show Your True Colors
Customize editor colors
Easier to read and easier to identify editing errors
IBM Rational Software Development Conference 2006
SQ147
Tip 5: Interacting With ScriptsTip 5: Interacting With Scripts
You can stop your scripts and display or enter values while the script plays back via message windows
The script will not continue until tester acknowledges!
Alert the tester that they need to act using Beep
Message Box toOutput Messages
Password Box forHidden User Input
Input Box for UserInput
IBM Rational Software Development Conference 2006
SQ148
Tip 6: Log Messages To The Console Write yourself status messages while your script runs
Messages persist after script run
IBM Rational Software Development Conference 2006
SQ149
Tip 7: Writing Messages To The Test Log
Use the SQALogMessage command
Can report information in test log like calculated results and variable contents
IBM Rational Software Development Conference 2006
SQ1410
Tip 8: Suspending Log Output
Control what does and what does not get written to the Test Log
IBM Rational Software Development Conference 2006
SQ1411
Tip 9: You Have Mail Online User Group
Independent Mail List
http://www.dundee.net/sqa/
File Archive on Yahoo!
http://groups.yahoo.com/group/RationalUsers/
IBM developerWorks
www.ibm.com/developerWorks
Message Board
Utilities, code
Articles, tutorials
IBM Rational Software Development Conference 2006
SQ1412
Tip 10: Dealing with Long Lines
Open “C:\DATA\UserInfo.TXT” for Input as #1
Do While Not EOF(1)
Input #1, FirstName, LastName, HomePhone, OfficePhone, …
Code…Code…Code…
Loop
Open “C:\DATA\UserInfo.TXT” for Input as #1
Do While Not EOF(1)
Input #1, FirstName, LastName, HomePhone, OfficePhone, …
Code…Code…Code…
Loop
IBM Rational Software Development Conference 2006
SQ1413
Tip 10: Dealing with Long Lines
Open “C:\DATA\UserInfo.TXT” for Input as #1
Do While Not EOF(1)
Input #1, FirstName, _
LastName, _
HomePhone, _
OfficePhone, _
City, _
State, _
ZipCode
Code…Code…Code…
Loop
Open “C:\DATA\UserInfo.TXT” for Input as #1
Do While Not EOF(1)
Input #1, FirstName, _
LastName, _
HomePhone, _
OfficePhone, _
City, _
State, _
ZipCode
Code…Code…Code…
Loop
Line continuation character _Allows long commands _to be split across _multiple lines
IBM Rational Software Development Conference 2006
SQ1414
Tip 11: HELP ME!
Press F1 on any SQABasic keyword to get context sensitive help
SQABasic keywords are always in Blue
F1F1F1
IBM Rational Software Development Conference 2006
SQ1415
Tip 12: Ahhh, Just Skip It! Problem:Need to skip over portions of script
Solution #1:•Use Auto-comment
•CTRL M & U
Problem:Need to skip over portions of script
Solution #1:•Use Auto-comment
•CTRL M & U
IBM Rational Software Development Conference 2006
SQ1416
Tip 12: Ahhh, Just Skip It!
Notes:• Colon (:) on label• Label left justified
Notes:• Colon (:) on label• Label left justified
Problem:Need to skip over portions of script
Solution #2:Use Goto Label
Problem:Need to skip over portions of script
Solution #2:Use Goto Label
IBM Rational Software Development Conference 2006
SQ1417
Tip 12: Ahhh, Just Skip It! Problem:Need to skip over portions of script
Solution #3:If you just want to stop at a certain point…
•Click on line where you want to stop
•Use Go Until Cursor• F6 key
Problem:Need to skip over portions of script
Solution #3:If you just want to stop at a certain point…
•Click on line where you want to stop
•Use Go Until Cursor• F6 key
IBM Rational Software Development Conference 2006
SQ1418
Tip 13: Check This One Out
Record
Edit & Playback
IBM Rational Software Development Conference 2006
SQ1419
Tip 14 – Just Hangin’ Around Robot hovers over objects
without clicking!
Turn on/off with CTRL-SHIFT-P
Length of time before
“MousePause”is recorded
IBM Rational Software Development Conference 2006
SQ1420
Agenda
Beginner level
Intermediate level
Advanced level
IBM Rational Software Development Conference 2006
SQ1421
Tip 15 – Clip and Save
Robot has read/write access to the Windows Clipboard text
Copy info to the Clipboard during recording and use it in your scripts
Set info to the Clipboard in one script for use in another
Clipboard.GetText
Clipboard.SetText
IBM Rational Software Development Conference 2006
SQ1422
Tip 16: Public Property
All of the properties available from an Object Properties VP are accessible programmatically
SQAGetProperty
Will return the value of a property
SQASetProperty
Will set the value of a property
IBM Rational Software Development Conference 2006
SQ1423
Tip 16: Public Property
Record
Edit & Playback
IBM Rational Software Development Conference 2006
SQ1424
Tip 16: Public Property
Note: Must specify “Type”
IBM Rational Software Development Conference 2006
SQ1425
Tip 16: Public Property
Problem:Actions on MSFlexGrid and other grid controls recorded as Generic Object
Problem:Actions on MSFlexGrid and other grid controls recorded as Generic Object
Solution:Re-code to useSQASetPropertySQAGetProperty
Solution:Re-code to useSQASetPropertySQAGetProperty
2
IBM Rational Software Development Conference 2006
SQ1426
Tip 17: Name That Name
Problem:
The trick with SQAGetProperty and SQASetProperty is to specify the correct recognition string
IBM Rational Software Development Conference 2006
SQ1427
Tip 17: Name That Name
Solution:
Use SQAGetChildren
Lists recognition strings for all objects on screen
IBM Rational Software Development Conference 2006
SQ1428
Tip 18 - Go Go Gadget Inspector
Inspects objects
Capture recognition strings
IBM Rational Software Development Conference 2006
SQ1429
Tip 19: What A Drag
Drag and Drop across windows is impossible with Robot Recorder All Robot actions are based on top left corner of context window. It
can’t “see” outside the current context window.
IBM Rational Software Development Conference 2006
SQ1430
Tip 19: What A Drag
Solution:
Use Win32 API
GetCursorPos
Get the current cursor position
Mouse_Event
Perform mouse actions
SetCursorPos
Set the cursor position
Method:Find source and target cursor
(x,y) coordinatesGo to starting coordinatesClick down on mouseGo to ending coordinatesRelease mouse
Method:Find source and target cursor
(x,y) coordinatesGo to starting coordinatesClick down on mouseGo to ending coordinatesRelease mouse
IBM Rational Software Development Conference 2006
SQ1431
Tip 20: Take Off From The Command Line
You can launch Robot from the command line
Can use Windows Scheduler to launch Robot at a certain time
Command line syntax is in the Robot Help
Not the SQA Basic Help!
IBM Rational Software Development Conference 2006
SQ1432
Tip 20: Take Off From The Command Line
Enclose any item with spaces “in quotes”
If no password is necessary, don’t specify password item
Project field is full path to *.RSP file
Build & Log Folder must exist
Log File does not need to exist
Easiest to copy code to batch file for execution
rtrobo.exe [scriptname] [/user userid] [/password password] [/project full path and full projectname] [/play] [/purify] [/quantify] [/coverage][/build build] [/logfolder foldername] [/log logname] [/nolog] [/close]
rtrobo.exertrobo.exe [[scriptnamescriptname] [/user ] [/user useriduserid] [/password password] ] [/password password] [/project full path and full [/project full path and full projectnameprojectname] [/play] [/purify] ] [/play] [/purify] [/quantify] [/coverage][/build build] [/[/quantify] [/coverage][/build build] [/logfolderlogfolder foldernamefoldername] ] [/log [/log lognamelogname] [/] [/nolognolog] [/close] ] [/close]
Format:Format:Format:
rtrobo.exe "Tip 04-Interacting With Scripts" /user admin /project "C:\Rational Tips 2002\Tips Repository\Rational Tips 2002.rsp"/play /build "Build 1" /logfolder "Default" /log MyLog /close
rtrobo.exertrobo.exe "Tip 04"Tip 04--Interacting With Scripts"Interacting With Scripts" /user /user adminadmin /project /project "C:"C:\\Rational Tips 2002Rational Tips 2002\\Tips RepositoryTips Repository\\Rational Tips 2002.rsp"Rational Tips 2002.rsp"/play /build /play /build "Build 1""Build 1" //logfolderlogfolder "Default""Default" /log /log MyLogMyLog /close /close
Sample:Sample:Sample:
IBM Rational Software Development Conference 2006
SQ1433
Tip 21 – I Could Tell You……but then I Would Have to Kill You
Problem:
Passwords captured during recording are readable in the script
IBM Rational Software Development Conference 2006
SQ1434
Tip 21 – I Could Tell You……but then I Would Have to Kill You
Or is it a problem???
SR4 automatically encrypts passwords!
IBM Rational Software Development Conference 2006
SQ1435
Tip 21 – I Could Tell You……but then I Would Have to Kill You
Or is it a problem???
SR4 automatically encrypts passwords!
Disclaimers:
No decrypt capability
That’s kinda the point, isn’t it?
No external encrypt capability
No ability to turn it off
Only supports HTML, C++ Win32 & MFC
No VB, .NET WinForms, or Java
IBM Rational Software Development Conference 2006
SQ1436
Tip 22: I May Still Need to Kill You
Problem:So what about VB, Java, .NET,
etc?
Solutions:PasswordBox function
See Tip 4: Interacting with Scripts
Low Level Recording
Encrypt the password externally
…or a little razzle-dazzle!
IBM Rational Software Development Conference 2006
SQ1437
Tip 22: I May Still Need to Kill YouStep 1: Record
normally
Step 2: Open any HTML form and enter the
same password
Step 3: Continue recording
IBM Rational Software Development Conference 2006
SQ1438
Tip 22: I May Still Need to Kill YouStep 1: Record
normally
Step 3: Continue recording
Step 2: Open any HTML form and enter the
same password
Step 4: Delete the InputKeysand any extra
context commands
IBM Rational Software Development Conference 2006
SQ1439
Agenda
Beginner level
Intermediate level
Advanced level
IBM Rational Software Development Conference 2006
SQ1440
What’s in your toolbox?
Application Services: COM & API
Software components that provide services to other applications
Many sources
Windows components
3rd Party Applications
Homegrown
Stand Alone Utilities
Executables that provide additional functionality to Robot
Often created by Robot users or available as general utilities
IBM Rational Software Development Conference 2006
SQ1441
Tip 23: Office Integration
Leverage services of office automation solutions
Microsoft Word
Microsoft Excel
Microsoft Outlook
… oh yeah, and Lotus Notes
IBM Rational Software Development Conference 2006
SQ1442
Tip 23: Office Integration
Capture screen-shots to Word
Spell Check your application with Word
Read from and Write to Excel
Receive and Send Email with Outlook…
… oh yeah, and Lotus Notes
IBM Rational Software Development Conference 2006
SQ1443
Tip 24: Distributing the Workload
Single point of control for configuration testsUtilize multiple computers in parallel
Single reporting pointEnforce configuration choices, implement dependencies, and much more…
Test Station
Test Station
Test Station
IBM Rational Software Development Conference 2006
SQ1444
Tip 25: Pass the Note
Problem:
Scripts running on multiple computers are in independent process spaces
How can you communicate between them?
TestManager Suites provide Shared Variables, but SQABasic doesn’t support them
Shared Variables are only integers
IBM Rational Software Development Conference 2006
SQ1445
Tip 25: Pass the Note
Solution:
Use Java script to “expose” shared variable to Robot scripts
Shared integer variable acts as semaphore
More complex data passed in files or database
IBM Rational Software Development Conference 2006
SQ1446
Tip 25: Pass the NoteHow’d he do that? Declare SV in Java
import com.rational.test.tss.*;
public class SharedVar extends com.rational.test.tss.TestScript {
// Extend the SharedVarInfo class.public static class SharedVarConfig extends SharedVarInfo {
public SharedVarConfig() {String sv[] = { "CharState" };setSharedVarNames(sv);
}}
// Main test routine that will be executed by TestManager.public void testMain(String[] args) {
// Do absolutely nothing!}
}
SharedVar.java:
IBM Rational Software Development Conference 2006
SQ1447
Tip 25: Pass the NoteHow’d he do that? Synchronize library in Robot
Set TSSSync = CreateObject("TestScriptServices.TSSSync")ResponseState = 0
Initialize:
ResponseState = ResponseState + 1Result = TSSSync.SharedVarAssign ("CharState", ResponseState)
Signal an Event (i.e. Merlin is done talking):
Result = TSSSync.SharedVarWait("CharState", _ResponseState + 1, _ResponseState + 1, _0, _-1)
ResponseState = ResponseState + 1
Wait For Event (i.e. Wait for Peedy to finish talking):
GLOBAL ResponseState As Integer ‘ Local image of SVGLOBAL TSSSync As Object ‘ Services Object
Declarations:
IBM Rational Software Development Conference 2006
SQ1448
What’s in your toolbox?
Application Services: COM & API
Software components that provide services to other applications
Many sources
Windows components
3rd Party Applications
Homegrown
Stand Alone Utilities
Executables that provide additional functionality to Robot
Often created by Robot users or available as general utilities
IBM Rational Software Development Conference 2006
SQ1449
Tip 26: Find the Needle…
Problem
Long scripts and especially libraries are difficult to navigate
Solution
Use the Robot Code Browser!
Quickly navigate through Robot code
IBM Rational Software Development Conference 2006
SQ1450
Tip 27: Can You See the Difference?
Problem:
Robot’s native image comparator gives pass / fail
Solution:
Use Image Comparator utility to set tolerance
IBM Rational Software Development Conference 2006
SQ1451
Tip 28: Get a Move On
Problem:
Manually moving scripts is tedious
Create new script in target project,
Copy all script files (rec, vp, sbh, sbl, rtxml*)
Not to mention it is unsupported!
Solution:
Use Robot Asset Import
IBM Rational Software Development Conference 2006
SQ1452
IBM Rational Software Development Conference 2006
SQ1453