RTL Default Components
RTL Default Components
Copyright 2010 SAP AG. All rights reserved. Java is a registered trademark of Sun Microsystems, Inc. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9, iSeries, pSeries, xSeries, zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other countries. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Any Java Source Code delivered with this product is only to be used by SAPs Support Services and may not be modified or altered in any way. Documentation in the SAP Service Marketplace You can find this documentation at the following address:
http://service.sap.com/instguides
JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, xApps, xApp, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.
Disclaimer Some components of this product are based on Java. Any code change in these components may cause unpredictable and severe malfunctions and is therefore expressively prohibited, as is any decompilation of these components.
Table of Contents
Foreword....................................................................................................................................................... 9 Runtime Library Improvements .................................................................................................................... 9 Terminology ................................................................................................................................................ 11 Test.......................................................................................................................................................... 11 Component ............................................................................................................................................. 11 Consolidated Component ....................................................................................................................... 11 Process Flow Analyzer............................................................................................................................. 11 SAP Test Acceleration and Optimization Object Spy .............................................................................. 12 Runtime Library Concepts ........................................................................................................................... 14 Uniform Resource Identifier ................................................................................................................... 14 SAP Test Acceleration and Optimization Execution Context .................................................................. 16 Encoded Characters ................................................................................................................................ 19 Runtime Library Features............................................................................................................................ 21 CBASE Configuration ............................................................................................................................... 21 Configuration Properties............................................................................................................................. 21 Test Acceleration and Optimization Reports .......................................................................................... 23 SAP Front End SAP Test Acceleration and Optimization Libraries ........................................................... 25 CBASE ...................................................................................................................................................... 25 Runtime Initialization .......................................................................................................................... 26 Bootstrap Library ................................................................................................................................ 27 Core Libraries ...................................................................................................................................... 27 SAP Front End Test Acceleration and Optimization Components ........................................................... 31 Overview ................................................................................................................................................. 31 Component Categories ............................................................................................................................... 31 Standard Component Behavior .............................................................................................................. 31 Component Category: Actions ................................................................................................................ 32 Component Category: Controls .............................................................................................................. 33 Action Components .................................................................................................................................... 37 Actions\CaptureScreen ....................................................................................................................... 37
Actions\CheckTransactionCode .......................................................................................................... 37 Actions\CloseWindow......................................................................................................................... 38 Actions\EndTransaction ...................................................................................................................... 38 Actions\ExecuteStatement ................................................................................................................. 39 Actions\InitializeContext ..................................................................................................................... 41 Actions\LaunchAndLogin .................................................................................................................... 42 Actions\LogOff .................................................................................................................................... 42 Actions\PressKey................................................................................................................................. 43 Actions\StartTransaction .................................................................................................................... 44 Actions\Wait ....................................................................................................................................... 44 Actions\DataTable\SetDataTable ....................................................................................................... 45 Actions\DataTable\SetDataTableRow ................................................................................................ 45 Actions\DataTable\TransferData ........................................................................................................ 45 Actions\Report\ReportMessage ......................................................................................................... 47 Actions\Verifications\CompareValues................................................................................................ 48 Actions\Verifications\SetCondition .................................................................................................... 49 Actions\Verifications\RemoveCondition ............................................................................................ 51 Generic Components .................................................................................................................................. 52 Controls\CheckProperty ..................................................................................................................... 52 Controls\GetProperty ......................................................................................................................... 56 Controls\GetText ................................................................................................................................ 58 Controls\SetFocus ............................................................................................................................... 61 Controls\SetProperty .......................................................................................................................... 62 Controls\SetText ................................................................................................................................. 63 Control-Specific Components ..................................................................................................................... 66 Controls\GuiButton\Press................................................................................................................... 66 Controls\GuiCheckbox\GetSelected ................................................................................................... 66 Controls\GuiCheckbox\SetSelected .................................................................................................... 67 Controls\GuiComboBox\GetKey ......................................................................................................... 67 2010 SAP AG Page 4 of 147
Controls\GuiComboBox\GetValue ...................................................................................................... 68 Controls\GuiComboBox\SetKey.......................................................................................................... 68 Controls\GuiComboBox\SetValue ...................................................................................................... 69 Controls\GuiGridView\ClearSelection ................................................................................................ 70 Controls\GuiGridView\ClickCurrentCell.............................................................................................. 70 Controls\GuiGridView\DeleteRows .................................................................................................... 70 Controls\GuiGridView\DeselectColumn ............................................................................................. 71 Controls\GuiGridView\DoubleClickCurrentCell .................................................................................. 72 Controls\GuiGridView\DuplicateRows ............................................................................................... 72 Controls\GuiGridView\GetCellCheckBoxChecked .............................................................................. 74 Controls\GuiGridView\GetCellState ................................................................................................... 76 Controls\GuiGridView\GetCellValue .................................................................................................. 77 Controls\GuiGridView\InsertRows ..................................................................................................... 78 Controls\GuiGridView\ModifyCell ...................................................................................................... 78 Controls\GuiGridView\ModifyCheckBox ............................................................................................ 80 Controls\GuiGridView\MoveRows ..................................................................................................... 80 Controls\GuiGridView\PressButton.................................................................................................... 81 Controls\GuiGridView\PressColumnHeader ...................................................................................... 81 Controls\GuiGridView\PressEnter ...................................................................................................... 82 Controls\GuiGridView\PressF1 ........................................................................................................... 82 Controls\GuiGridView\PressF4 ........................................................................................................... 82 Controls\GuiGridView\PressToolbarButton ....................................................................................... 83 Controls\GuiGridView\PressToolbarContextMenuItem..................................................................... 83 Controls\GuiGridView\SelectAll ......................................................................................................... 84 Controls\GuiGridView\SelectColumn ................................................................................................. 84 Controls\GuiGridView\SelectContextMenuItem ................................................................................ 85 Controls\GuiGridView\SetCurrentCell ................................................................................................ 85 Controls\GuiGridView\SetSelectedRows ............................................................................................ 86 Controls\GuiMenu\Select ................................................................................................................... 87 2010 SAP AG Page 5 of 147
Controls\GuiPasswordField\SetSecureText ........................................................................................ 87 Controls\GuiRadioButton\GetSelected .............................................................................................. 89 Controls\GuiRadioButton\SetSelected ............................................................................................... 89 Controls\GuiStatusbar\GetMessageParameter.................................................................................. 90 Controls\GuiStatusbar\GetMessageParameters ................................................................................ 90 Controls\GuiStatusbar\GetMessageType ........................................................................................... 91 Controls\GuiTab\Select....................................................................................................................... 93 Controls\GuiTabStrip\GetSelectedTab ............................................................................................... 94 Controls\GuiTableControl\GetCellData .............................................................................................. 95 Controls\GuiTableControl\SetCellData............................................................................................... 96 Controls\GuiTableControl\IsRowSelected .......................................................................................... 96 Controls\GuiTableControl\SelectRow ................................................................................................ 97 Controls\GuiTextEdit\DoubleClick ...................................................................................................... 97 Controls\GuiTextEdit\PressF4............................................................................................................. 98 Controls\GuiToolbarControl\PressButton .......................................................................................... 99 Controls\GuiToolbarControl\PressContextButton ............................................................................. 99 Controls\GuiToolbarControl\SelectContextMenuItem .................................................................... 100 Controls\GuiTree\ChangeCheckbox ................................................................................................. 102 Controls\GuiTree\ClickLink ............................................................................................................... 102 Controls\GuiTree\CollapseNode....................................................................................................... 104 Controls\GuiTree\DoubleClickItem .................................................................................................. 104 Controls\GuiTree\DoubleClickNode ................................................................................................. 105 Controls\GuiTree\ExpandNode ........................................................................................................ 106 Controls\GuiTree\GetCheckBoxState ............................................................................................... 107 Controls\GuiTree\PressButton ......................................................................................................... 108 Controls\GuiTree\SelectColum ......................................................................................................... 109 Controls\GuiTree\SelectColumnContextMenuItem ......................................................................... 110 Controls\GuiTree\SelectContextMenuItem ..................................................................................... 112 Controls\GuiTree\SelectItem ............................................................................................................ 113 2010 SAP AG Page 6 of 147
Controls\GuiTree\SelectNode .......................................................................................................... 114 Controls\GuiTree\SetCheckBoxState ................................................................................................ 115 Controls\GuiTree\UnselectAll ........................................................................................................... 115 Controls\GuiTree\UnselectColum .................................................................................................... 116 Controls\GuiTree\UnselectNode ...................................................................................................... 118 Frequently Asked Questions ..................................................................................................................... 120 How to use the component Actions/Verifications/SetCondition? ....................................................... 120 How to use Component GuiTree/SelectColumnContextMenuItem? ................................................... 125 Test Automation of Dynamic Scenarios .................................................................................................... 130 Searching for Controls using their Text................................................................................................. 130 Searching for Child Elements using their Text ...................................................................................... 131 Customizing the Runtime Library.......................................................................................................... 132 Adding Custom Code:........................................................................................................................ 132 Verifying the Syntax of Custom Code: .............................................................................................. 133 Invoking the Custom Code: ............................................................................................................... 134 Runtime Library API .................................................................................................................................. 135 TAO Class............................................................................................................................................... 135 Function GetSAPGUIConnection() .................................................................................................... 136 Function GetSAPGUISession() ........................................................................................................... 136 Function GetControl( Uri ) ................................................................................................................ 136 Function ResolveParameterValue( Parameter ) ............................................................................... 137 Sub Report( Severity, Topic, Message, Options ) ............................................................................. 137 Sub Log( message )............................................................................................................................ 138 Sub CaptureScreen() ......................................................................................................................... 138 Sub Wait( milliseconds ) .................................................................................................................... 138 Sub LoadLibrary( Library ) ................................................................................................................. 139 Advanced Concepts................................................................................................................................... 140 Debugging the CBASE............................................................................................................................ 140 Uploading the libraries to SAP Quality Center .................................................................................. 140 2010 SAP AG Page 7 of 147
Declaring the Libraries in the Application Area ................................................................................ 141 Modifying the Application Area with HP QuickTest Professional ..................................................... 141 Starting a Debug Session................................................................................................................... 144 Putting a Breakpoint in a Library ...................................................................................................... 145 Appendix ................................................................................................................................................... 146 SAP GuiScripting Type ........................................................................................................................... 146
2010 SAP AG
Page 8 of 147
Foreword
The runtime library of SAP Test Acceleration and Optimization 2.0 (SP02) contains a new set of libraries and components, which have been designed to exploit the capabilities of the well-defined SAP GuiScripting API.
2010 SAP AG
Page 9 of 147
The SAP Test Acceleration and Optimization components can store information in a shared context, also known as the TAO Execution Context. This makes it easier to test complex scenarios, in which the result of a first transaction is the input to the next one. The performance of tests has been improved. Performance is stable even when the execution context is not the expected one.
2010 SAP AG
Page 10 of 147
Terminology
Test
A test is an entity persisted in SAP Quality Center application by HP. The tests generated by SAP Test Acceleration and Optimization are composite objects, containing: a set of components a list of input parameters a Microsoft Excel file providing the input parameter values (also known as the data table)
Component
A Component is an entity persisted in SAP Quality Center. SAP Test Acceleration and Optimization delivers a set of default components that are to be exported (uploaded) to the SAP Quality Center repository. Each SAP Test Acceleration and Optimization component contains VB script coding to call the relevant component implementation in the SAP Test Acceleration and Optimization Runtime Library.
Consolidated Component
The consolidation of components is an SAP Test Acceleration and Optimization concept to merge all components used by a test into a single component. The goal of the consolidation is: To improve the reusability of test scenarios. Each consolidated component can be reused in other test scenario with different parameters. To improve the performance of the test by getting rid of the QTP initialization overhead.
2010 SAP AG
Page 11 of 147
2010 SAP AG
Page 12 of 147
2010 SAP AG
Page 13 of 147
URI Syntax:
The URI is composed of key-value pairs, separated by a semicolon and a space character. For example label=<controlLabel>; type=<controlType>; id=<controlId> A typical URI provides the ID of the control and its type. The ID is used to search for the control using the official SAP GuiScripting API. The type is used to ensure that the object found matches the expected one. If this is not the case, the test reports an error. Additional information is not mandatory. The label can be specified, to improve the feedback written to the SAP Test Acceleration and Optimization report when an error occurs during the test.
As an alternative to the ID, the URI can provide the name of the control, as shown below: label=<controlLabel>; type=<controlType>; name=<controlName> This is not the recommended way to identify a control, because a naming conflict may occur. The syntax is only supported for backward compatibility.
2010 SAP AG
As shown here the ID can be relative but providing a full ID (with information about the connection and the session) is also supported by the runtime library.
2010 SAP AG
Page 15 of 147
FF_QTP_DataTable_Path=C:\SAPTAO\DATA\Order2Cash.xls
This is no longer the case when running a test based on SAP Test Acceleration and Optimization 2.0 SP02. The equivalent of those OS Environment variables is now stored in the SAP Test Acceleration and Optimization Execution Context.
Variables
With SAP Test Acceleration and Optimization 2.0 SP02, the SAP Test Acceleration and Optimization Execution Context can be populated with computed values. The typical use case is to dynamically create a variable, in which the result of a scenario is stored and made available to subsequent components. For example, the business scenario could be to use the VA21 transaction to create a quotation, and use the ID of the newly-created quotation in the VA01 transaction to create a sales order. This typical scenario can be automated using the GuiStatubar\GetMessageParameters component. This component retrieves the parameter values of the status bar and stores them in variables that are prefixed by the transaction code. For instance the status bar of the VA21 transaction creates the following variables: VA21_MessageStatus VA21_MessageParameter0 VA21_MessageParameter1
The next component will be able to retrieve the value from SAP Test Acceleration and Optimization Execution Context by using the corresponding token as input parameter. The tokens matching the variables created by the VA21 transaction are: %VA21_MessageStatus% %VA21_MessageParameter0% %VA21_MessageParameter1%
The information retrieved from the GuiStatusbar is visible in the SAP Test Acceleration and Optimization report, as shown below:
2010 SAP AG
Page 17 of 147
The runtime library resolves the value of each component parameter by replacing each token with the value of the corresponding variable.
Example of TargetField: DT_ORDER_TYPE- Because of the DT_ prefix, this TargetField example searches for the DT_ORDER_TYPE column in the excel-sheet and updates the corresponding cell. orderType No prefix is used, this creates a variable in the SAP Test Acceleration and Optimization execution context the token to retrieve it is then %orderType%.
Token Resolution
The concept of tokens has been introduced, to make it easier to pass information between components. All component parameters (including the Uri parameter) can use tokens. Each time a component starts, the runtime library looks for tokens, and replaces them with the value of the corresponding variable. When the token has the prefix DT_, the actual value is retrieved from the data table; the Microsoft Excel sheet associated with the test. Page 18 of 147
2010 SAP AG
When the prefix DT_ is not used, the actual value is retrieved directly from the SAP Test Acceleration and Optimization Execution Context. In such situations, the component assumes that the corresponding variable has been populated using a component that gets a property value e.g. : GetProperty component.
Standard Tokens
Some tokens are standard keywords that can be used to dynamically retrieve information about the execution context. Standard SAP Test Acceleration and Optimization tokens are: %activeWindow% - the index of the current window 0 for the main window %today% - the current date %yesterday% - yesterdays date %tomorrow% - tomorrows date %random% - a random number %windowType% - the type of the active window %windowTitle% - the window title %screenNumber% - the screen number of the current SAP GUI session %transactionCode% - the current transaction code %sessionNumber% - the current SAP GUI session number
Encoded Characters
The percent character is the one used to detect SAP Test Acceleration and Optimization tokens. As a consequence this character must be encoded to avoid conflicts during the resolution of the parameter values. Other characters are encoded as well to address technical restrictions or avoid syntax errors in the VB scripts associated to consolidated components.
Encoded characters:
%percent% - the % character %dollar% - the dollar character ($ ) %quote% - the quote character ( ) %cr% - the carriage return character CHR(13) %lf% - the line feed character CHR(10) %crlf% - the consecutive CR LF characters CHR(13)+CHR(10) Page 19 of 147
2010 SAP AG
%blank% - an empty string to distinguish a parameter not set (Null), from an explicit empty string. %space% - a space character to avoid trimming the parameter values.
2010 SAP AG
Page 20 of 147
Configuration Properties
Description
When true, the SAP GUI object targeted by the current action is highlighted before performing the action. ENABLE_STATUS_WINDOW Obsolete When true, the Notepad application displays the execution steps. ENABLE_TAO_REPORT When true, the test generates an SAP Test Acceleration and Optimization report. This report provides feedback to the user, and helps to troubleshoot the test. ENABLE_DEBUG_LOG Activates the debug traces to help troubleshoot the test. ENABLE_QC_REPORT Enable/Disable QC Reporting features. ENABLE_CAPTURE_SCREEN Set this option to FALSE to turn off all screenshot captures. ENABLE_CAPTURE_SCREEN_ON_ERROR When an error is raised, a screenshot of the current screen is captured and TRUE TRUE TRUE TRUE TRUE FALSE
2010 SAP AG
Page 21 of 147
added to the Test Acceleration and Optimization Report. ENABLE_SCROLL_ON_CAPTURE_SCREEN Set this option to TRUE to get several screenshots when the window has vertical scroll bars. DEBUG_ON When true, a breakpoint is added on the Test Acceleration and Optimization exception handler, to DEBUG the component. FALSE FALSE
2010 SAP AG
Page 22 of 147
The content of the folder differs according to the RTL configuration. In the default configuration, the folder contains:
REPORTLOG.XML The generated Test Acceleration and Optimization Report with a status of each step performed during the test execution
2010 SAP AG
Page 23 of 147
LOG.XSLT A style sheet to display the SAP Test Acceleration and Optimization report in a browser
The images subfolder may contain the screenshots captured during the test execution.
2010 SAP AG
Page 24 of 147
SAP Test Acceleration and Optimization Self-Check The configuration of the CBASE is a prerequisite of test automation with SAP Test Acceleration and Optimization. Use the Self-Check to verify that the SAP Test Acceleration and Optimization set-up is consistent. The FF_ROOT_PATH must end with a backslash.
2010 SAP AG
Page 25 of 147
Runtime Initialization
At runtime, the component initialization automatically loads the core libraries that are declared in the SAP Test Acceleration and Optimization configuration. The prerequisite is to upload the CBASE_Init.vbs.txt file to SAP Quality Center at: [Test Plan]\Subject\BPT Resources\Libraries\CBASE_Init.vbs.txt.
Note
All SAP Test Acceleration and Optimization components rely on the CBASE_Init.vbs.txt file. The component name starts with: ExecuteFile "[QualityCenter] Subject\BPT Resources\Libraries\CBASE_Init.vbs.txt". Depending on the SAP Quality Center, it may be necessary to create this path manually.
2010 SAP AG
Page 26 of 147
Bootstrap Library
CBASE_init.vbs.txt is the entry point to the runtime library initialization. The initialization steps are performed by the bootstrap library CBASE\CBASE_Bootstrap.vbs. This bootstrap library is responsible for: Reading the CBASE.Config file Initializing the SAP Test Acceleration and Optimization execution context Loading all other core libraries Initializing the log & traces Initializing the SAP Test Acceleration and Optimization report
Core Libraries
The core libraries are compatible with SAP Test Acceleration and Optimization 1.0, and SAP Test Acceleration and Optimization 2.0 SP1. These libraries support existing tests built on the components of the previous runtime library. They are not used any more by the test generated by the PFA, except for some core features like logging and reporting. CBASE_Foundation_DT.vbs CBASE_Foundation_Reports.vbs CBASE_Foundation_Utilities.vbs CBASE_SAP_47_Gets.vbs CBASE_SAP_47_Lib.vbs CBASE_SAP_47_Verifications.vbs CBASE_SAP_47_Wrappers.vbs CBASE_TAO_47_Wrappers.vbs
2010 SAP AG
Obsolete Libraries
Some libraries are no longer recommended because they provided features not officially supported by SAP Test Acceleration and Optimization. They have been moved into a dedicated subfolder, and they are no longer loaded when using the default CBASE configuration. CBASE_Init.vbs When loaded, this LIB informs you that the SAP Test Acceleration and Optimization setup is not correct ObsoleteLibraries\CBASE_Foundation_Global.vbs ObsoleteLibraries\ CBASE_Foundation_Wrappers.vbs ObsoleteLibraries\ CBASE_Obsolete.vbs ObsoleteLibraries\ CBASE_WEB_Gets.vbs
2010 SAP AG
Page 28 of 147
Hot Fixes
When a problem is detected in the runtime library, the official way to fix it is to wait for the next patch of SAP Test Acceleration and Optimization. The HotFixes subfolder has been introduced because this sometimes takes too long. This folder is used by SAP support to deliver hot fixes which are not yet available as a patch. This library is delivered empty with official SAP Test Acceleration and Optimization releases. You should not change this folder manually.
Custom Functions
Customer scenarios may require features that are not supported by the runtime library. In such a situation, put the custom coding in a dedicated library which is loaded by default and delivered empty in official SAP Test Acceleration and Optimization releases. Use a customer-specific prefix when adding new features in this library, to avoid naming conflicts with existing functions and global variables. Do not use this library to override existing functions. The official way to correct an existing function is to contact SAP support and get a hot fix which has to be deployed using the CBASE_HotFixes.vbs library.
Control Libraries
With the new runtime library, the SAP Test Acceleration and Optimization components are only a view of the underlying SAP GuiScripting API. Each component matches one of the public methods (or properties) shown by the SAP GUI controls. The libraries containing the invocation of the targeted COM objects are: GS_GuiButton.vbs GS_GuiCheckBox.vbs GS_GuiComboBox.vbs GS_GuiGridView.vbs GS_GuiGridView_Impl.vbs GS_GuiMenu.vbs GS_GuiPasswordField_Impl.vbs GS_GuiRadioButton.vbs GS_GuiStatusbar.vbs GS_GuiStatusbar_Impl.vbs GS_GuiTab.vbs Page 29 of 147
2010 SAP AG
Note
Some controls, such as GuiTree, have two libraries. This is because the generated code had to be change manually, to make it compliant with the SAP GuiScripting recorded event. For example, it is not possible to click on an item of a context menu without opening the menu first. The generated libraries have been changed to take care of such situations.
Libraries On-Demand
Unlike core libraries, the control libraries are not loaded at script initialization, to improve the QTP performance and avoid the load of unused VB script coding. Each component loads the required library using the ImportType statement. For instance, the GuiButton\Press component imports the GuiButton libraries.
' TAO Component: GuiButton - Press ExecuteFile "[QualityCenter] Subject\BPT Resources\Libraries\CBASE_Init.vbs.txt" ImportType "GuiButton"
2010 SAP AG
Page 30 of 147
Component Categories
We distinguish several categories of components. Each category has subfolders, in which components are grouped by their nature. Components of the Actions category perform SAP GUI-specific operations like starting a transaction. Components of the Controls category target a specific control like a button or a text field.
Check a value against the expected one Make the information available to subsequent components
Expected Value
Get components have an ExpectedValue parameter. When this parameter is specified, the runtime library checks whether the retrieved value matches the expected one. If this is not the case, the test reports an error No check is performed when the parameter is empty The %blank% token checks against an empty string
Target Field
Get components also have a TargetField parameter. When this parameter is specified, the retrieved value is persisted to make it available to subsequent components. If the DT_ prefix is used the data table associated to the test is updated. If the DT_ prefix is not used, a variable is created and its value is persisted in the SAP Test Acceleration and Optimization execution context. The variable will be accessible by subsequent components by tokens. For more information on variables, see SAP TAO Execution Context on page 16.
Actions\Data Source
SetDataSource Page 32 of 147
2010 SAP AG
SetDataSourceCursor TransferData
Actions\Report
ReportMessage
Actions\Verification
CompareValues SetCondition RemoveCondition
Controls\GuiButton
Press
Controls\GuiCheckBox
GetSelected SetSelected
Controls\GuiComboBox
GetKey GetValue SetKey SetValue Page 33 of 147
2010 SAP AG
Controls\GuiGridView
ClearSelection ClickCurrentCell DeleteRows DeselectColumn DoubleClickCurrentCell DuplicateRows GetCellCheckBoxChecked GetCellState GetCellValue InsertRows ModifyCell ModifyCheckBox MoveRows PressButton PressColumnHeader PressEnter PressF1 PressF4 PressToolbarButton PressToolbarContextMenuItem SelectAll SelectColumn SelectContextMenuItem SetCurrentCell SetSelectedRows
Controls\GuiMenu
Select
Controls\GuiPasswordField
SetSecureText
Controls\GuiRadioButton
GetSelected SetSelected Page 34 of 147
2010 SAP AG
Controls\GuiStatusbar
GetMessageParameter GetMessageParameters GetMessageType
Controls\GuiTab
Select
Controls\GuiTableControl
GetCellData SelectedRow SelectRow SetCellData
Controls\GuiTabStrip
GetSelectedTab
Controls\GuiTextedit
DoubleClick PressF4
Controls\GuiToolbarControl
PressButton PressContextButton SelectContextMenuItem
Controls\GuiTree
ChangeCheckbox ClickLink CollapseNode DoubleClickItem DoubleClickNode ExpandNode GetCheckBoxState PressButton SelectColumn Page 35 of 147
2010 SAP AG
2010 SAP AG
Page 36 of 147
Action Components
Actions\CaptureScreen The CaptureScreen component is captures a screenshot of the active window of the SAP GUI session. The persisted screenshot will be visible in the SAP Test Acceleration and Optimization report. Default screenshot format is PNG Default location for screenshot is <FF_ROOT_PATH>Logs\<TestName>\Images
Component Parameters
OPTIONS Reserved for future use
Component Configuration
You can enable or disable the capture of screenshots using the CBASE configuration.
Known Limitations
The screenshot capture is done using the Hardcopy method of the SAP GuiScripting API. This method does not work properly when the computer is locked, or the screen saver is running.
Actions\CheckTransactionCode The CheckTransactionCode component checks whether the current transaction is the one expected by the scenario being tested. The check result is in the SAP Test Acceleration and Optimization Report. The test status is PASSED when the transaction is the correct one Otherwise the test status is FAILED
Component Parameters
EXPECTEDTRANSACTIONCODE Specifies the expected transaction code 2010 SAP AG Page 37 of 147
OPTIONS /x (exit) Interrupts the test execution when the current transaction is not the expected one /c (capture) Captures a screenshot of the active window if the transaction is not the expected one
Actions\CloseWindow The CloseWindow component closes the specified window. It emulates a mouse click on the button to close a popup window.
Component Parameters
URI URI specifies the URI of the targeted window. For more information, refer the URI syntax on page 14. OPTIONS Reserved for future use.
Component Parameters
OPTIONS Reserved for future use.
2010 SAP AG
Page 38 of 147
Actions\ExecuteStatement The ExecuteStatement component provides the ability to call custom functions (or subroutines) that are responsible for solving dynamic scenarios. The advantage of such approach is that the tester does not need to create any component. He/she can simply put custom code in a dedicated library and call it directly.
Component Parameters
LIBRARY The Library parameter is the relative path, from the CBASE folder, of the library which contains the statement to execute.
STATEMENT
The Statement parameter provides the instruction to be executed. OPTIONS Reserved for future use.
Note
The statement specified will typically invoke a subroutine or a function and will be executed by the VB Script interpreter. Please make sure the syntax of the statement is correct. Like all Default Components, the STATEMENT parameter can use tokens to retrieve the value of a variable from the SAP Test Acceleration and Optimization Execution Context. The library GS_TAO is loaded automatically when using this component. This library contains a class which exposes useful functions. More information on page 135.
2010 SAP AG
Page 39 of 147
Example using a token to log the current Transaction Code. Note the usage of the quotes here. This is necessary since the Log subroutine expects a string as input parameter.
TAO.Log %transactionCode%
Example using a variable to log the current Transaction Code. The two lines below are equivalent. Note that the quotes are useless in both cases.
TAO.Log $transactionCode$ TAO.Log InterpretToken(transactionCode)
Example using a information coming from the DataTable. Note that the DT_ prefix is used here.
TAO.Log $DT_TRANSACTIONCODE$
2010 SAP AG
Page 40 of 147
Actions\InitializeContext The InitializeContext component initializes the SAP Test Acceleration and Optimization Execution Context. You must start your test composition with this component to properly initialize all areas. There are three test initialization parameters. You can use their default values unless you need to modify the standard behavior.
Component Parameters
TESTOPTIONS The TestOptions parameter activates options that may impact all subsequent components. /n (for new) creates a new execution context This is the default. /c (for continue) preserves the previous execution context. This option is typically used to generate a single SAP Test Acceleration and Optimization report while using iterations in SAP Quality Center. /x (for exit) Interrupts the test execution on the first error detected. You can ignore this option if it conflicts with other options, such as the DEBUG_ON mode that can be activated in the CBASE Configuration. /locale=en-us Enforces English as the locale used by the VB Script interpreter when formatting and converting numbers. The option can enforce other language settings as well. /prefix=DT _ Declares the prefix used to externalize the actual parameter value in the DataTable i.e. the Excel sheet associated with the test. The prefix DT_ is the default value when this option is not used.
DATATABLEPATH The DataTablePath parameter specifies the path to the Microsoft Excel file containing the values of the input parameters. The values in the Microsoft Excel file are loaded at component start-up, and made available using the DataTable object of QuickTest Professional.
DATATABLEROW The DatatTableRow parameter specifies row from which to get input values. By default the value should be 1.
2010 SAP AG
Page 41 of 147
Known Limitation
The test initialization fails if the DataTablePath refers to a Microsoft Excel file which is not accessible, or is locked by another process.
Actions\LaunchAndLogin The LaunchAndLogin component initializes the SAP GUI session to be used by all subsequent components.
Component Parameters
SAPSYSTEM SAPSYSTEM specifies the SAP system to connect to. The component checks the SAPLOGON configuration for a matching entry and uses this data to create the connection. SAPCLIENT Specifies the client number SAPUSER Specifies the name of the login user SAPPASSWORD SAPPASSWORD specifies the password of the user. Make it secure using the QTP Password Encoder. SAPLANGUAGE SAPLANGUAGE specifies the preferred language. For example, EN (for English) or JA (for Japanese). Test execution using QTP is sensitive to language-specific data formats. Use the language of the data in the DataTable. SAPOPTIONS /r (resize) Resizes the main window according to CBASE configuration.
Actions\LogOff The LogOff component logs off from the SAP System. This ends the SAP GUI Session. 2010 SAP AG Page 42 of 147
Component Parameters
OPTIONS Reserved for future use
Actions\PressKey The PressKey component emulates the action made by the user while pressing a key.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted window. For more information, see the URI syntax on page 14. KEY KEY specifies the key code pressed. The key code can be a numeric value or a string. Use the PFA to record the appropriate value. OPTIONS Reserved for future use
Key Codes
The list below shows the mapping between the numeric key code and its equivalent string. Both formats can be used without any side-effects. The string representation of the key does not dependent on the user language. 0 1 2 3 9 10 11 12 13 Enter F1 F2 F9 F10 F11 ESC Shift+F1 Page 43 of 147
2010 SAP AG
14 15 24 37 38 39
Actions\StartTransaction The StartTransaction component starts a transaction. The session should have been started using the LaunchAndLogin component. If this is not the case, the operation is performed against the first available SAPGUI session.
Component Parameters
SAPTRANSACTIONCODE SAPTRANSACTIONCODE is the code of the transaction to be started. OPTIONS Reserved for future use
Actions\Wait The Wait component can make the Test Execution pause for a certain time before proceeding.
Component Parameters
THEVALUE Specifies the waiting time in milliseconds OPTIONS Reserved for future use
2010 SAP AG
Page 44 of 147
Actions\DataTable\SetDataTable The SetDataTable component is used the data source of component parameters. Normally this operation is not necessary, because this declaration is also performed by the Actions\InitializeContext component.
Component Parameters
DATATABLEPATH DATATABLEPATH specifies the path to the Microsoft Excel file containing the values of the input parameters. The values in the Microsoft Excel file are loaded at component startup, and made available using the Quick Test Pro DataTable object.
DATATABLEROW DATATABLEROW specifies the row from which to get input values. By default, the value should be 1.
Known Limitation
An error occurs when the DataTablePath refers to a Microsoft Excel file which is not accessible, or is locked by another process.
Actions\DataTable\SetDataTableRow This component changes the row from which to retrieve values from the QTP DataTable object. This information is also declared by the Actions\InitializeContext component.
Component Parameters
DATATABLEROW DATATABLEROW specifies the row from which to get input values. By default, the value should be 1.
Actions\DataTable\TransferData The TransferData component copies information from the current data source to another.
2010 SAP AG
Page 45 of 147
Component Parameters
SOURCEFIELD SOURCEFIELD specifies the name of the field to be copied. It is the name of the column in the Microsoft Excel sheet. TARGETPATH TARGETPATH specifies the path to the Microsoft Excel file to be updated. TARGETROW TARGETROW specifies the row to be used in the targeted Microsoft Excel sheet. TARGETFIELD TARGETFIELD is the name of the column in the target Microsoft Excel sheet. It is optional. If empty, the SourceField is used.
Notes
This component is only for backward compatibility. It is better to pass information between components using variables, and put the information in the SAP Test Acceleration and Optimization Execution Context. For more information on variables, refer to page 16.
2010 SAP AG
Page 46 of 147
Actions\Report\ReportMessage The ReportMessage component troubleshoots complex scenarios by adding custom messages to the SAP Test Acceleration and Optimization Report.
Component Parameters
SEVERITY The severity of the message INFO, WARNING, DONE, FAILED TOPIC The Topic parameter is a short text to categorize the message. MESSAGE Any message can be specified here. OPTIONS Reserved for future use
Notes
Like all component parameters, the MESSAGE parameter can use tokens to retrieve the value of a variable from the SAP Test Acceleration and Optimization Execution Context. For instance, one could include the ID of an order created by transaction VA01, in a message, using the message below: Standard order %VA01_MessageParameter1% has been created
2010 SAP AG
Page 47 of 147
Actions\Verifications\CompareValues The CompareValues component compares two values by evaluating a Boolean expression. The test fails and reports an error when the expression evaluation returns false. The component also captures a screenshot of the current screen when the test fails.
Component Parameters
SAPVALUE1 SAPVALUE1 specifies the first value; the left-hand operand of the expression to evaluate. The value specified here will typically be a token that has been previously set using a getter component; a component expecting a TargetField parameter such as the GetProperty and the GetMessageParameter component. SAPVALUE2 SAPVALUE2 specifies the second value; the right-hand operand of the expression to evaluate. The value specified can use the prefix DT_ to get the actual value from the DataTable. COMPARISONOPERATOR The operator must specify a Boolean operator to compare the two operands. The operators supported are the ones the VB Script language can interpret. = < > >= <= <> Equal to Lower than Greater than Greater than or equal to Less than or equal to Not equal to
OPTIONS The options parameter enforces a type conversion before the comparison. /i (integer) 2010 SAP AG Both values are converted to an integer before being compared Page 48 of 147
/f (float) /b (bool)
Both values are converted to a float (or double) before being compared Both values are converted to a Boolean before being compared
The locale of the VB Script interpreter (which depends on the language settings of the operating system) may have an effect when converting string values to numerical values. To address conversion issues, you may need to enforce the locale via the InitializeContext component TestOptions parameter. The example below shows how to enforce English as default locale. TestOptions /locale=en-us
Actions\Verifications\SetCondition The SetCondition component declares a condition. The condition will be used by subsequent Test Components to determine whether they have to perform their operation.
Component Parameters
NAME A name to identify the condition any string can be used here SAPCONDITION SAPCONDITION is an expression that is to be checked by subsequent test components. OPTIONS /o (only once) the condition will be checked only once.
Expression Evaluation
The SAPCONDITION parameter must provide a boolean expression which can be evaluated by the VB script interpreter. For example, one could declare a condition to check whether the current window is a popup, and thus ensure only performing the subsequent actions when the condition is met. A typical use case is to exit from a popup window which appears from time to time, depending on some external application events. 2010 SAP AG Page 49 of 147
Expression Persistence
All declared conditions have a name. They are persisted in the SAP Test Acceleration and Optimization execution context, and by default made available during the entire test execution. The tester must use the Actions\Verifications\RemoveCondition component to remove a condition. The OPTIONS parameter can be set to /o to automatically remove the condition from the next component execution.
See Also
For more information on how to use the SetCondition component, refer to the section How to use the component Actions/Verifications/SetCondition, on page 120.
2010 SAP AG
Page 50 of 147
Actions\Verifications\RemoveCondition The RemoveCondition component removes a condition that has been declared previously, using the Actions\Verifications\SetCondition component.
Component Parameters
NAME The name of a previously-declared condition OPTIONS /a (all) when the name is omitted the /a option removes all conditions at once.
2010 SAP AG
Page 51 of 147
Generic Components
Controls\CheckProperty The CheckProperty component is a generic component to retrieve and check the value of the properties exposed by SAP GuiScripting Controls.
Component Parameters
URI The Uri specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. PROPERTYNAME The name of the property whose value is to be retrieved. OPERATOR The operator must specify a Boolean operator to compare the actual value with the expected one. The operators supported are the ones the VB Script language can interpret. = < > >= <= <> Equal to Lower than Greater than Greater than or equal to Less than or equal to Not equal to
EXPECTEDVALUE The expected value is the value that should be retrieved from the targeted control. The component will report an error if the value is not the expected one The check is not made when this parameter is left empty Use the %blank% token to enforce the check against an empty value Page 52 of 147
2010 SAP AG
OPTIONS The options parameter enforces a type conversion before comparing the actual value with the expected value. /i (integer) /f (float) /b (bool) Both values are converted to an integer before being compared Both values are converted to a float (or double) before being compared Both values are converted to a Boolean before being compared
The locale of the VB Script interpreter (which depends on the language settings of the operating system) may have an effect when converting string values to numerical values. To address conversion issues, you may need to enforce the locale via the InitializeContext component TestOptions parameter. The example below shows how to enforce English as default locale. TestOptions /locale=en-us
Additional supported options: /t (trim) Both values are trimmed before being compared. This might be useful when comparing an empty string and a space character. Interrupts the Test Execution when the comparison fails
/x (exit)
2010 SAP AG
Page 53 of 147
For more information about the Check Picker, refer to the SAP Test Acceleration and Optimization User Guide.
Example
The example below shows how to check the actual value of the Text property of the PO Number text field.
PARAMETERS
Uri
2010 SAP AG
Page 54 of 147
2010 SAP AG
Page 55 of 147
Controls\GetProperty The GetProperty component is a generic component to retrieve the value of the properties of the targeted SAP GUI objects.
Component Parameters
URI The Uri parameter specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. PROPERTYNAME Specifies the name of the property whose value is to be retrieved The list of public properties available depends on the type of control targeted. Refer to the official SAP GuiScripting Help (delivered with the SAP Front End) for the complete list of public properties. EXPECTEDVALUE The expected value TARGETFIELD This parameter specifies the column of the data table in which to persist the retrieved value, or the name of a variable of the SAP Test Acceleration and Optimization Execution Context.
Note
This get component has standard behavior. See the expected value and the target field semantic on page 31.
2010 SAP AG
ID Name Type
Uri
Explanations
The expected value being specified, the component will (at runtime) check that the actual row count matches the expected one. If this is not the case the test will fail.
2010 SAP AG
Page 57 of 147
The TargetField declares where to put the actual value of the rowcount property. Because the TargetField starts with the DT_ prefix the actual value will be stored in the DataTable associated to the Test (i.e.: in the Excel-sheet).
Controls\GetText The GetText generic component gets the value of the targeted SAP GUI objects. This component is similar to the Controls\GetProperty component when Text is specified as PropertyName.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. EXPECTEDVALUE The expected value of the Text property. TARGETFIELD TARGETFIELD specifies where to persist the retrieved value.
Note
This get component has standard behavior. See the expected value and the target field semantic on page 31.
Uri
Expected Value
2010 SAP AG
Page 58 of 147
TargetField Explanations
incoterms_actual_value
In this example, the expected value has been left empty, so the component will not check the actual value at runtime, but the TargetField parameter as been specified. The actual value of the control will be copied into the variable incoterms_actual_value, which will be accessible by the subsequent components via the corresponding token, %incoterms_actual_value% You can store the actual value of the control in the data table associated with the test, by specifying a target field starting with the prefix DT_. For more details, refer to the target field semantic on page 31. Screenshot of Transaction VA03 Display Standard Order
2010 SAP AG
Page 59 of 147
With this second example an expected value is being specified while the target field has been left empty. As a consequence, the component will (at runtime) compare the actual value of the control with the ZB01 expected value. If the two values are different then test fails and the SAP Test Acceleration and Optimization Report shows the root cause of the error. Screenshot of Transaction VA03 Display Standard Order
2010 SAP AG
Page 60 of 147
Controls\SetFocus The SetFocus generic component puts the focus on the targeted SAP GUI objects. This operation is normally not necessary because most of the Sap GuiScripting operations do not require that the targeted control gets the focus first. However, some coding (on the server side) may check whether the focus was set properly. In that situation, an explicit invocation of the SetFocus method might be necessary to make the test run properly.
Component Parameters
URI The Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14.
2010 SAP AG
Page 61 of 147
Controls\SetProperty SetProperty is a generic component. It changes the value of properties exposed by the SAP GuiScripting Objects. It does not work when targeting read-only properties.
Component Parameters
URI The Uniform Resource Identifier of the targeted object. For more information, see the URI syntax on page 14. PROPERTYNAME The name of the public property exposed by the targeted object. The list of public properties available depends on the type of control targeted. Refer to the official SAP GuiScripting Help (delivered with the SAP Front End) for the complete list of public properties. THEVALUE The new value of the property.
Known Limitations
The value must have the format the targeted property expects. The runtime library does not check the format. For example, if the targeted property expects a date, the input parameter must provide the date in the appropriate format.
2010 SAP AG
Page 62 of 147
Controls\SetText The SetText generic component sets the value of Text property of the targeted control. This is similar to the SetProperty component when the PropertyName is Text.
Component Parameters
URI Specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. THEVALUE Specifies the new value of the targeted control; the new value of the Text property.
Known Limitations
The value must match the format of the targeted SAP GUI Control. The runtime library does not check the format. For example, if the targeted control expects a date, the input parameter must provide the date in the appropriate format.
Miscellaneous
This component is used by the Process Flow Analyzer. Text field assignments are commonly done using this component. Assigning the cell value in a table control also relies on this component.
See Also
If the targeted control expects a Boolean value it is preferable to use the dedicated component, which converts the input value appropriately. Examples: GuiCheckbox/SetSelected the recommended way to change the state of a checkbox. GuiRadioButton/SetSelected the recommended way to change the state of a radio button.
2010 SAP AG
Page 63 of 147
Value
2010 SAP AG
Page 64 of 147
Value
2010 SAP AG
Page 65 of 147
Control-Specific Components
Controls\GuiButton\Press The Press component emulates a click on the targeted button.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the target GuiButton object. For more information, refer to the URI syntax on page 14.
Controls\GuiCheckbox\GetSelected The GetSelected component gets the state of the targeted checkbox.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. EXPECTEDVALUE Specifies the expected state (True or False) TARGETFIELD Specifies where to persist the retrieved value
Note
This get component has standard behavior. See the expected value and the target field semantic on page 31.
2010 SAP AG
Page 66 of 147
Controls\GuiCheckbox\SetSelected The SetSelected component changes the state of the targeted checkbox.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. THEVALUE Specifies the new state of the checkbox (true or false)
Note
No operation is performed if the value is empty.
Controls\GuiComboBox\GetKey The GetKey component gets the key of the selected entry.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, see the URI syntax on page 14. EXPECTEDVALUE Specifies the expected value of the key TARGETFIELD Specifies where to persist the retrieved value
Note
This get component has standard behavior. See the expected value and the target field semantic on page 31.
2010 SAP AG
Page 67 of 147
Controls\GuiComboBox\GetValue The GetValue component gets the value of the selected entry.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. EXPECTEDVALUE Specifies the expected value TARGETFIELD Specifies where to persist the retrieved value
Note
This get component has standard behavior. See the expected value and the target field semantic on page 31.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. THEVALUE Specifies the key of the entry to be selected
2010 SAP AG
Page 68 of 147
Controls\GuiComboBox\SetValue The SetValue component selects one of the combobox entries. This component is not recommended because the behavior is language-dependent. The GuiCombobox\SetKey component should be used instead.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. THEVALUE Specifies the value of the entry to be selected
2010 SAP AG
Page 69 of 147
Controls\GuiGridView\ClearSelection The ClearSelection component clears the selection of the targeted grid.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted control. For more information, refer to the URI syntax on page 14.
Controls\GuiGridView\ClickCurrentCell The ClickCurrentCell component emulates a mouse click on the current cell of the target grid.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted control. For more information, refer to the URI syntax on page 14.
Note
The behavior of this component depends on the state of the target control. Set the current cell first, using the GuiGridView\SetCurrentCell component.
Controls\GuiGridView\DeleteRows The DeleteRows component deletes rows from the targeted grid.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the target control. For more information, refer to the URI syntax on page 14. ROWS ROWS specifies the (zero-based) row number that is to be removed from the grid. 2010 SAP AG Page 70 of 147
This parameter also supports a comma-separated string of indexes or index ranges; for example 3, 5-8, 14, 15. The indexes must be ordered and should not overlap. For more information on how to use index ranges, refer to the official SAP GuiScripting Help delivered with the SAP Front End.
Controls\GuiGridView\DeselectColumn The DeselectColumn component removes the specified column from the set of selected columns.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the target control. For more information, refer to the URI syntax on page 14. COLUMN Specifies the name of the column
Example
PARAMETERS
Uri
Column
2010 SAP AG
Page 71 of 147
Controls\GuiGridView\DoubleClickCurrentCell The DoubleClickCurrentCell component emulates a mouse double-click on the current cell of the target grid.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the target control. For more information, refer to the URI syntax on page 14.
Note
The behavior of this component depends on the state of the target control. Set the current cell first, using the GuiGridView\SetCurrentCell component.
Controls\GuiGridView\DuplicateRows The DuplicateRows component duplicates some rows of the target grid.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the target control. For more information, refer to the URI syntax on page 14. ROWS Specifies the (zero-based) row number that is to be duplicated
Example
This example shows how to duplicate the second row.
PARAMETERS
Uri
Rows
2010 SAP AG
Page 72 of 147
Advanced Use-cases
The Rows parameter also supports a comma-separated string of indexes or index ranges; for example 3, 5-8, 14, 15. If a range of indexes is duplicated, all the new lines are inserted as one block, before the old lines. The indexes must be ordered and should not overlap. For more information on how to use index ranges please refer to the official SAP GuiScripting Help delivered with the SAP Front End). Example of a grid containing two rows:
2010 SAP AG
Page 73 of 147
Controls\GuiGridView\GetCellCheckBoxChecked The GetCellCheckBoxChecked component gets the state of a checkbox in a grid. The regular GuiCheckBox\GetSelected cannot be used here because additional information is required to find a check box control embedded within a GuiGridView control.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted control. For more information, refer to the URI syntax on page 14. ROW ROW specifies the row number of the checkbox. Note that the row number property starts at zero. COLUMN Specifies the column name of the checkbox EXPECTEDVALUE Specifies the expected state (True or False) TARGETFIELD Specifies the location to persist the retrieved value
Note
This get component has standard behavior. See the expected value and the target field semantic on page 31.
Example
This example checks that the checkbox of the first line is not checked.
PARAMETERS
Uri
ExpectedValue
False
2010 SAP AG
Page 75 of 147
Controls\GuiGridView\GetCellState The GetCellState component retrieves the state of a cell in a grid. According to the SAP GuiScripting documentation, the possible values are: Normal Error Warning Info
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted control. For more information, refer to the URI syntax on page 14. ROW Specifies the row number of the cell COLUMN Specifies the column name of the cell EXPECTEDVALUE Specifies the expected state TARGETFIELD Specifies where to persist the retrieved value
Note
This get component has standard behavior. See the expected value and the target field semantic on page 31.
2010 SAP AG
Page 76 of 147
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted control. For more information, refer to the URI syntax on page 14. ROW ROW specifies the row number of the cell. COLUMN Specifies the column name of the cell EXPECTEDVALUE Specifies the expected state TARGETFIELD Specifies where to persist the retrieved value
Note
This get component has standard behavior. See the expected value and the target field semantic on page 31.
2010 SAP AG
Page 77 of 147
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted control. For more information, refer to the URI syntax on page 14. ROWS ROWS specifies a comma-separated text of indexes or index ranges; for example 3, 5-8, 14, 15. A new row will be added at the given index, moving the old row one line down. If a range of indexes is inserted, all the new lines are inserted as one block, before any of the old lines. The entries must be ordered and not overlap, otherwise an exception is thrown. For more information on how to use index ranges, refer to the official SAP GuiScripting Help delivered with the SAP Front End).
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. ROW Specifies the row number of the cell COLUMN Specifies the column name of the cell THEVALUE Specifies the new value of the targeted cell 2010 SAP AG Page 78 of 147
2010 SAP AG
Page 79 of 147
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. ROW Specifies the row number of the cell COLUMN Specifies the column name of the cell CHECKED Specifies the new checkbox state (True or False)
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. FROMROW Specifies the index of the first row to move TOROW Specifies the index of the last row to move DESTROW Specifies where to move the selected rows to 2010 SAP AG Page 80 of 147
Controls\GuiGridView\PressButton The PressButton component emulates a mouse click on a button in a cell. The component reports an error, if the targeted cell does not contain a button.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. ROW Specifies the row number of the cell COLUMN Specifies the column name of the cell
Controls\GuiGridView\PressColumnHeader The PressColumnHeader component emulates a mouse click on the header of the column.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. COLUMN COLUMN specifies the column name. The component reports an error, if the column parameter does not identify a valid column.
2010 SAP AG
Page 81 of 147
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, see the URI syntax on page 14.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14.
2010 SAP AG
Page 82 of 147
Controls\GuiGridView\PressToolbarButton The PressToolbarButton component emulates a mouse click in a button on the toolbar of a grid. It is not the same as the PressButton that is responsible for clicking in a button in the grid itself, not in the toolbar.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. ID The button ID
Controls\GuiGridView\PressToolbarContextMenuItem The PressToolbarContextMenuItem component emulates selecting an item in the context menu of a button in the toolbar attached to the targeted grid.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. BUTTONID Specifies the button ID FUNCTIONCODE Specifies the menu item to be selected. By default the component expects the code of the context menu item. The text can be specified instead when the Options parameter is set to /pt. OPTIONS /pt Use this option when the FunctionCode parameter provides the text instead of the code of the context menu item . Page 83 of 147
2010 SAP AG
Recommendations
Use the Process Flow Analyzer to determine the expected values of the ButtonId and the FunctionCode. The SAP Test Acceleration and Optimization Object Spy also provides this information, but it might be difficult to find it on a complex UI.
Controls\GuiGridView\SelectAll The SelectAll component selects the whole grid content (all rows and all columns).
Component Parameters
URI The Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. COLUMN COLUMN specifies the column name. The component reports an error, if the column parameter does not identify a valid column.
2010 SAP AG
Page 84 of 147
Controls\GuiGridView\SelectContextMenuItem The SelectContextMenuItem component emulates selecting an item in the context menu of the target grid. The component for opening the menu does not exist; this operation is implicit at runtime when executing a test.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. FUNCTIONCODE FunctionCode specifies the code of the context menu item to be selected. By default the component expects the code of the context menu item. The text can be specified instead when the Options parameter is set to /pt. OPTIONS /pt Use this option when the FunctionCode parameter provides the text instead of the code of the context menu item .
Note
Use the Process Flow Analyzer to determine the expected values of the FunctionCode. The SAP Object Spy also provides the information, but might be difficult to find it on a complex UI.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14.
2010 SAP AG
Page 85 of 147
ROW Specifies the row number of the cell COLUMN Specifies the column name of the cell
Note
If row and column identify a valid cell, this cell becomes the current cell. Otherwise, an exception is raised.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. THEVALUE Specifies the index of the row to select
Advanced Use-cases
The Rows parameter also supports a comma-separated string of indexes or index ranges; for example 3, 5-8, 14, 15. For more information on how to use index ranges, refer to the official SAP GuiScripting Help delivered with the SAP Front End).
2010 SAP AG
Page 86 of 147
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted GuiMenu object. For more information, refer to the URI syntax on page 14.
Example
PARAMETERS Uri label=Project/New/Project; type=GuiMenu; id=/app/con[0]/ses[0]/wnd[0]/mbar/menu[0]/menu[0]/menu[0]
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14.
2010 SAP AG
Page 87 of 147
THEVALUE Specifies the encrypted value of the password OPTIONS Reserved for future use
Note
This component supports password encryption using the QTP Password Encoder. The SapPassword used by the LaunchAndLogin component relies on the same encryption algorithm.
2010 SAP AG
Page 88 of 147
Controls\GuiRadioButton\GetSelected The GetSelected component gets the state of the target radio button element.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. EXPECTEDVALUE Specifies the expected state (True or False) TARGETFIELD Specifies where to persist the retrieved value
Note
This get component has standard behavior. See the expected value and the target field semantic on page 31.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. THEVALUE Specifies the new state (true or false)
Note
No operation is performed if the specified value is empty. 2010 SAP AG Page 89 of 147
Controls\GuiStatusbar\GetMessageParameter The GetMessageParameter component gets the value of one of the message parameters of the Status Bar.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the target status bar. For more information, refer to the URI syntax on page 14. INDEX Specifies the index of the parameter (starting at 0) TARGETFIELD TARGETFIELD specifies where to persist the retrieved value. For more information, refer to the target field semantic on page 31.
Controls\GuiStatusbar\GetMessageParameters The GetMessageParameters component gets the values of all message parameters in the status bar.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the target status bar. For more information, see the URI syntax on page 14. EXPECTEDMESSAGETYPE Specifies the expected message type The possible message types are: S W E A I Success Warning Error Abort Information Page 90 of 147
2010 SAP AG
OPTIONS /s (save) Puts the message parameter values in the SAP Test Acceleration and Optimization Execution Context.
Note
When the ExpectedMessageType parameter is specified, the runtime library checks whether the retrieved value matches the expected one. If this is not the case, the test reports an error. Leave the parameter empty, to avoid checking the value
With the /s option, all message parameters are put in the SAP Test Acceleration and Optimization execution context, to make the information available to subsequent components. This creates a dedicated variable per message parameter. The name of the variable is prefixed by the current transaction code. The subsequent component can retrieve the persisted values using the corresponding tokens: %VA21_MessageStatus% %VA21_MessageParameter0% %VA21_MessageParameter1%
Miscellaneous
The Process Flow Analyzer uses this component to persist the result of the last message of type Success (S). This is helpful for testing complex business scenarios, in which the result of the first transaction is an input parameter of the next one.
Controls\GuiStatusbar\GetMessageType The GetMessageType component gets the value of one of the MessageType properties in the status bar.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the target status bar. For more information, refer to the URI syntax on page 14.
2010 SAP AG
Page 91 of 147
EXPECTEDVALUE Specifies the expected message type. The possible message types are: S W E A I Success Warning Error Abort Information
TARGETFIELD TARGETFIELD specifies where to persist the retrieved value. For more information, refer to the target field semantic on page 31.
Miscellaneous
The Process Flow Analyzer uses this component to ensure that the behavior of a test scenario is consistent at runtime. The runtime library assumes that the message type recorded by a PFA matches the message type that the component retrieves during the test. This check is made even if the initial message type was an error (E).
2010 SAP AG
Page 92 of 147
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14.
Example
The example below shows how to select a tab within a tab strip.
PARAMETERS
Uri
2010 SAP AG
Page 93 of 147
Controls\GuiTabStrip\GetSelectedTab The GetSelectedTab component gets the index of the currently selected tab page within a GuiTabStrip.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the GuiTabStrip container. For more information, refer to the URI syntax on page 14. EXPECTEDVALUE Specifies the expected index. The test fails, and reports an error, when the selected tab is not the expected one. TARGETFIELD Specifies where to persist the retrieved value
Note
This get component has standard behavior. Refer to the expected value and the target field semantic on page 31.
Example
The example below shows how to check that a tab is selected.
PARAMETERS
In this example the TargetField parameter is left empty because we only need to check that the tab is selected.
2010 SAP AG
Page 94 of 147
Controls\GuiTableControl\GetCellData The GetCellData component gets the value of a cell in a table. This component only exists for convenience and for backward compatibility to previous versions of tests generated by SAP Test Acceleration and Optimization 2.0. This operation can be performed using the generic Controls\GetText component which is much faster.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. ROW Specifies the row number (starting at 0) COLUMN Specifies the column number (starting at 0) TARGETFIELD TARGETFIELD specifies where to persist the retrieved value. For more information, refer to the target field semantic on page 31.
2010 SAP AG
Page 95 of 147
Controls\GuiTableControl\SetCellData The SetCellData component sets the value of a cell in a table. This component only exists for convenience and for backward compatibility to previous versions of tests generated by SAP Test Acceleration and Optimization 2.0. This operation can be performed using the Controls\SetText generic component which is much faster.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. ROW Specifies the row number (starting at 0) COLUMN Specifies the column number (starting at 0) THEVALUE Specifies the new value of the cell
Controls\GuiTableControl\IsRowSelected The IsRowSelected component determines whether the specified row is part of the current selection.
Component Parameters
URI Specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. INDEX Specifies the row number (starting at 0) 2010 SAP AG Page 96 of 147
TARGETFIELD TARGETFIELD pecifies where to persist the retrieved value. For more information, refer to the target field semantic on page 31.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. INDEX Specifies the row number (starting at 0) THEVALUE THEVALUE specifies whether to select or unselect the row (True or False). For more information, refer to the target field semantic on page 31.
Controls\GuiTextEdit\DoubleClick The DoubleClick component emulates a mouse double click on a GuiTextEdit object.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14.
2010 SAP AG
Page 97 of 147
Controls\GuiTextEdit\PressF4 The PressF4 component emulates pressing the F4 key on a GuiTextEdit object.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14.
2010 SAP AG
Page 98 of 147
Controls\GuiToolbarControl\PressButton The PressButton component emulates pressing a button in the target toolbar control.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted GuiToolbarControl object. For more information, refer to the URI syntax on page 14. ID ID is the ID of the button to be pressed (not the ID of the Toolbar).
Example
This example shows how to press a button within a toolbar.
PARAMETERS
Uri Id
Controls\GuiToolbarControl\PressContextButton The PressContextButton component emulates pressing a context button in the target toolbar control.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted GuiToolbarControl object. For more information, refer to the URI syntax on page 14.
2010 SAP AG
Page 99 of 147
Example
This example shows how to press a context button within a toolbar.
PARAMETERS
Uri Id
Controls\GuiToolbarControl\SelectContextMenuItem The SelectContextMenuItem component selects an item from the context menu of the button targeted in a toolbar control. The component for opening the menu does not exist; this operation is implicit at runtime when executing a test.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. ID Specifies the ID of the button FUNCTIONCODE Specifies the function code of the item to be selected By default the component expects the code of the context menu item. The text can be specified instead when the Options parameter is set to /pt.
2010 SAP AG
OPTIONS /pt Use this option when the FunctionCode parameter provides the text instead of the code of the context menu item .
2010 SAP AG
Controls\GuiTree\ChangeCheckbox The ChangeCheckbox component changes the state of a checkbox in a tree control.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. NODEID The NodePath or the NodeKey of the targeted node. By default, the component expects a node path, unless the option /k is used. COLUMNNAME The name of the column THESTATE The new state of the targeted checkbox OPTIONS The Options parameter can declare whether the specified NodeId corresponds to the NodeKey or to the NodePath. /k (key) /pt Use this option when the NodeKey is specified This option can be used to search for the node using its text. More information on how to search nodes by text on page 131.
Controls\GuiTree\ClickLink The ClickLink component emulates a mouse click on a link in a tree control.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. 2010 SAP AG Page 102 of 147
NODEID NODEID specifies the NodePath or the NodeKey of the targeted node. By default, the component expects a node path, unless the option /k is used. COLUMNNAME Specifies the name of the column OPTIONS The Options parameter can be used to declare whether the specified NodeId corresponds to the NodeKey or to the NodePath. /k (key) /pt Use this option when the NodeKey is specified This option can be used to search for the node using its text. More information on how to search nodes by text on page 131.
2010 SAP AG
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. NODEID NODEID specifies the NodePath or the NodeKey of the targeted node. By default the component expects a node path unless the /k option is used. OPTIONS The Options parameter can be used to declare whether the NodeId specified corresponds to the NodeKey or to the NodePath. /k (key) /pt Use this option when the NodeKey is specified This option can be used to search for the node using its text. More information on how to search nodes by text on page 131.
Controls\GuiTree\DoubleClickItem The DoubleClickItem component emulates a mouse double click on an item in a tree control.
Component Parameters
URI The Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. NODEID NODEID specifies the NodePath or the NodeKey of the targeted node. By default, the component expects a node path, unless the option /k is used. 2010 SAP AG Page 104 of 147
COLUMNNAME Specifies the name of the column OPTIONS The Options parameter can declare whether the specified NodeId corresponds to the NodeKey or to the NodePath. /k (key) /pt Use this option when the NodeKey is specified This option can be used to search for the node using its text. More information on how to search nodes by text on page 131.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. NODEID The NodePath or the NodeKey of the targeted node. By default, the component expects a node path, unless the option /k is used. OPTIONS The Options parameter declares whether the NodeId specified corresponds to the NodeKey or to the NodePath. /k (key) /pt Use this option when the NodeKey is specified This option can be used to search for the node using its text. More information on how to search nodes by text on page 131.
2010 SAP AG
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. NODEID The NodePath or the NodeKey of the targeted node. By default, the component expects a node path, unless the option /k is used. OPTIONS The Options parameter declares whether the NodeId specified corresponds to the NodeKey or to the NodePath. /k (key) /pt Use this option when the NodeKey is specified This option can be used to search for the node using its text. More information on how to search nodes by text on page 131.
2010 SAP AG
Controls\GuiTree\GetCheckBoxState The GetCheckBoxState component gets the state of a checkbox in a tree control.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. NODEID The NodePath or the NodeKey of the targeted node. By default, the component expects a node path, unless the option /k is used. COLUMN NAME Specifies the name of the column EXPECTEDSTATE EXPECTEDSTATE specifies the expected state. For more information, refer to the expected value semantic on page 31. OPTIONS The Options parameter declares whether the NodeId specified corresponds to the NodeKey or to the NodePath. /k (key) /pt Use this option when the NodeKey is specified This option can be used to search for the node using its text. More information on how to search nodes by text on page 131.
2010 SAP AG
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. NODEID The NodePath or the NodeKey of the targeted node. By default, the component expects a node path, unless the option /k is used. COLUMNNAME Specifies the name of the column OPTIONS The Options parameter declares whether the NodeId specified corresponds to the NodeKey or to the NodePath. /k (key) /pt Use this option when the NodeKey is specified This option can be used to search for the node using its text. More information on how to search nodes by text on page 131.
2010 SAP AG
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. COLUMN NAME Specifies the name of the column OPTIONS The Options parameter declares whether the NodeId specified corresponds to the NodeKey or to the NodePath. /k (key) /pt Use this option when the NodeKey is specified This option can be used to search for the node using its text. More information on how to search nodes by text on page 131.
2010 SAP AG
Controls\GuiTree\SelectColumnContextMenuItem The SelectColumnContextMenuItem component triggers the selection of an item of the context menu of a certain node and column of the tree. The component for opening the menu does not exist; this operation is implicit at runtime when executing a test. Screenshot of Transaction KEPM Planning Framework
Component Parameters
URI The URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. 2010 SAP AG Page 110 of 147
NODEID NODEID specifies the NodePath or the NodeKey of the targeted node. By default the component expects a node path unless the /k option is used. COLUMNNAME Specifies the technical name of the column FUNCTIONCODE Specifies the menu item to be selected OPTIONS The Options parameter can be used to declare whether the NodeId specified corresponds to the NodeKey or to the NodePath. /k (key) /pt Use this option when the NodeKey is specified This option can be used to search for the node using its text. More information on how to search nodes by text on page 131.
Example
For more information on how to use this component and on how to determine the values it expects, refer to the section How to use Component GuiTree/SelectColumnContextMenuItem on page 125.
2010 SAP AG
Controls\GuiTree\SelectContextMenuItem The SelectContextMenuItem component emulates selecting an item in the context menu of the target tree. The component for opening the menu does not exist; this operation is implicit at runtime when executing a test.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. NODEID The NodePath or the NodeKey of the targeted node. By default, the component expects a node path, unless the option /k is used. FUNCTIONCODE The menu item to be selected OPTIONS The Options parameter declares whether the NodeId specified corresponds to the NodeKey or to the NodePath. /k (key) /pt Use this option when the NodeKey is specified This option can be used to search for the node using its text. More information on how to search nodes by text on page 131.
Example
This component is similar to SelectColumnContextMenuItem. For more information on how to use it, and on how to determine the values it expects, refer to the section How to use Component GuiTree/SelectColumnContextMenuItem on page 125.
2010 SAP AG
Component Parameters
URI The Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. NODEID The NodePath or the NodeKey of the targeted node. By default, the component expects a node path, unless the option /k is used. COLUMN NAME The name of the column OPTIONS The Options parameter declares whether the NodeId specified corresponds to the NodeKey or to the NodePath. /k (key) /pt Use this option when the NodeKey is specified This option can be used to search for the node using its text. More information on how to search nodes by text on page 131.
Example
This example shows how to select an item within a tree. PARAMETERS Uri label=Tree_SAP.TableTreeControl.1; type=GuiTree; id=/app/con[1]/ses[0]/wnd[0]/usr/cntlCC_CONTAINER/shellcont/shell /shellcont[1]/shell[1] 1
NodeId
2010 SAP AG
Controls\GuiTree\SelectNode The SelectNode component selects the specified node in a tree control.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. NODEID The NodePath or the NodeKey of the targeted node. By default, the component expects a node path, unless the option /k is used. OPTIONS The Options parameter declares whether the NodeId specified corresponds to the NodeKey or to the NodePath. /k (key) /pt Use this option when the NodeKey is specified This option can be used to search for the node using its text. More information on how to search nodes by text on page 131.
2010 SAP AG
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. NODEID The NodePath or the NodeKey of the targeted node. By default, the component expects a node path, unless the option /k is used. COLUMN NAME Specifies the name of the column THESTATE Specifies the new state of the checkbox OPTIONS The Options parameter declares whether the NodeId specified corresponds to the NodeKey or to the NodePath. /k (key) /pt Use this option when the NodeKey is specified This option can be used to search for the node using its text. More information on how to search nodes by text on page 131.
Controls\GuiTree\UnselectAll The UnselectAll component resets all selections in the target tree control.
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. 2010 SAP AG Page 115 of 147
Component Parameters
URI URI specifies the Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. COLUMNNAME Specifies the name of the column OPTIONS Reserved for future use
Example
This example shows how to deselect a column within a tree.
PARAMETERS
Uri
ColumnName Options
In this example, the Column Name includes space characters. Specify the exact value, as you retrieve it using the SAP Test Acceleration and Optimization Object Spy.
2010 SAP AG
2010 SAP AG
Component Parameters
URI The Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. NODEID The NodePath or the NodeKey of the targeted node. By default, the component expects a node path, unless the option /k is used. OPTIONS The options parameter declares whether the NodeId specified corresponds to the NodeKey or to the NodePath. /k (key) /pt Use this option when the NodeKey is specified This option can be used to search for the node using its text. More information on how to search nodes by text on page 131.
Example
This example shows how to deselect a node within a tree.
PARAMETERS
Uri
NodeId Options
2010 SAP AG
2010 SAP AG
2010 SAP AG
Test in SAP QUALITY Center The screenshot below shows a Test Composition corresponding to the described scenario.
Explanations
Initialization The test initialization does not contain anything special. It starts with the regular components: InitializeContext LaunchAndLogin StartTransaction
2010 SAP AG
Value Assignment The next step uses The SetText component to populate the value of the Quotation Type using DT_QUOTATION_TYPE value as specified in the excel-sheet. Value Retrieval Then the actual value of the control is retrieved using the GetText component. By setting the TargetField to ActualQuotationType, we ask the component to store the retrieved value in the Test Acceleration and Optimization Execution Context. The retrieved value is then made available to subsequent component as a regular token: %ActualContextType%
Setting the Condition Now we want to check whether the actual value differs from the one specified in the Excel-sheet. We use the SetCondition to specify the Boolean expression that all the subsequent components are going to check before performing any action. The condition used in this example is: $ActualQuotationType$<>$DT_QUOTATION_TYPE$ Evaluation Details Note the usage of the $ character instead of the % character here. This is used to postpone the evaluation of the token. Lets put it that way - the $ character behaves like a function call (or a variable) $ActualQuotationType$<>$DT_QUOTATION_TYPE$
While the % character surrounds the token representing the value itself. In other words, the syntax %ActualQuotationType%<>% DT_QUOTATION_TYPE%
2010 SAP AG
Is equivalent to (assuming that the value persisted in the Test Acceleration and Optimization Execution Context is correct) QT<>QT
The recommendation is to always use the $ character in conditions; this makes the syntax easier because no quotes are required to make the expression valid for the VB Script interpreter Retrieving Data From the Microsoft ExcelSheet As shown by this example, the token resolution also checks for the DT_ prefix and can then retrieve the value from the DataTable. Note that the Boolean expression will be interpreted by the VB Script Interpreter. As a consequence any VB Script functions can be used in the specified condition. In this example it would have been possible to directly invoke the ResolveValue function which is the one responsible for retrieving data from the DataTable. However this is not recommended because this ResolveValue is an internal function of the SAP Test Acceleration and Optimization Runtime Library and there is no guarantee that this function will still exist in future SAP Test Acceleration and Optimization releases. Reporting a Test Failure This step is only executed is the condition evaluation is true. It simply reports a Test failure and uses the %ActualQuotationType% to display the value which turns out to differ from the expected one. Setting the Second Condition With the componentization approach there is no way to simply declare the equivalent of the Else keyword which is common to all programming languages. The only option that we have here is simply to use again the SetCondition component but with the opposite condition. $ActualQuotationType$=$DT_QUOTATION_TYPE$
This time we check that the actual value equals the expected one. All subsequent components will evaluate the condition before performing any actions. Note that it is very important here to reuse the same condition name. That way the new condition replaces the previous one. With a different name both conditions will coexist and both conditions will be then evaluated before doing any actions!
2010 SAP AG
Reporting a Test Success This time we want to report a test success and make a capture of the current screen. This is typically done using the ReportMessage and the CaptureScreen components. Condition Removal The test ends by removing the condition. Note that if several conditions are coexisting, the /a options lets you remove all of them in one shot!
2010 SAP AG
2010 SAP AG
Technical name of the column Function code identifying the Item to be selected
None of the parameters require language-dependent values. This guarantees that the tests relying on such a component can run, even with different language settings.
2010 SAP AG
Spying using the SAP Test Acceleration and Optimization Object Spy Determining the relevant value without using the PFA is quite difficult because some dynamic parts of the UI such as the context menu are not visible when using the SAP Test Acceleration and Optimization Object Spy. The screenshot below shows the information available when spying the node in the tree. We can see here: The technical name of the columns of the tree The technical information of the node such as the node path And, of course, the Uri identifying the tree itself.
Unfortunately, the SAP Test Acceleration and Optimization Object Spy cannot display information about the Contextual Menu. Determining the FunctionCode is not possible here and the alternative is then to use the native SAP GUI Recording capabilities.
2010 SAP AG
Recording Using SAP Front End Recorder The SAP Front End and the underlying SAP GUI Technology has the ability to record user interactions. The recording can be started directly like shown in the screenshot below.
A dedicated toolbar let you record a scenario or play back an existing one.
Start the recording press the red icon, perform the selection of the item in the contextual menu and then stop the recording. The recorded scenario is persisted on the file system in a VB Script format.
2010 SAP AG
The generated VB Script can be opened using any text editor. The parameters required to perform the user action are visible like as regular VB Script parameters. With our example the expected value of the FunctionCode parameter is PLPCK_CH01.
Notes For convenience reasons the SelectColumnContextMenuItem component performs two atomic operations in one shot. It takes care to both emulate the right-click on the item (which is visible here as a call to the itemContextMenu function) and selects the item as well. The NodeKey or the NodePath can be specified as NodeId. By default the PFA generates a test relying on the NodePath. One may use the /k (for key) option to pass the NodeKey instead of the NodePath for identifying the targeted node in the tree.
2010 SAP AG
2010 SAP AG
2010 SAP AG
By default SAP recommends to put all custom subroutines and functions CBASE_Custom_Wrappers.vbs file which is delivered empty by official SAP TAO releases. Here is the content of the CBASE_Custom_Wrappers.vbs file.
'--------------------' Begin - Custom Code '--------------------' Put your custom code here - No custom code is delivered by SAP '--------------------' End - Custom Code '--------------------If Not IsEmpty(Environment) Or CBASE_BOOTSTRAP Then 'This line prevents from loading the library twice TaoExecutionContext().DeclareLibrary "CBASE_Custom_Wrappers.vbs" End If
Note that this VBScript file ends with a call the DeclareLibary method. This call is mandatory; it declares the current library to the TAO Execution Context to avoid loading the library several times when executing a Test.
2010 SAP AG
The CUSTOM_ prefix is used on purpose to make sure the custom code does not override a CaptureScreen subroutine or function that may exist somewhere else in the CBASE. The implementation of this subroutine can, of course, rely on existing functions made available by the SAP TAO Runtime Libraries. In this example, the CUSTOM_CaptureScreen subroutine relies on the TAO class to get access to the current SAP GUI session being tested. More information about this TAO class is provided in the next chapter.
Sub CUSTOM_CaptureScreen( windowTitle ) Dim activeWindow Set activeWindow = TAO.GetSapGuiSession().ActiveWindow If activeWindow.Text = windowTitle Then TAO.CaptureScreen() End If End Sub
2010 SAP AG
Example:
The example below will take a screenshot of the Contact Details window if any. PARAMETERS Library Statement Options 2010 SAP AG Page 134 of 147 CBASE_Custom_Wrappers.vbs CUSTOM_CaptureScreen Contact Details
TAO Class
The TAO class is a helper class where useful functions are made available to custom code. This class is part of the GS_TAO library which is implicitly loaded as soon as the ExecuteStatement component is used. The Runtime Library takes care to initialize the TAO object properly. The custom code can use it directly as we did in our CUSTOM_CaptureScreen example:
TAO.CaptureScreen()
2010 SAP AG
Function GetSAPGUIConnection() The GetSAPGUIConnection function retrieves the SAP Gui connection.
Return value
The SAP Gui connection (SAP Gui Scripting object).
Function GetSAPGUISession() The GetSAPGUISession function retrieves the SAP Gui session.
Return value
The SAP Gui session (SAP Gui Scripting object).
Function GetControl( Uri ) The GetControl function retrieves a reference to a SAP GUI Control. The control reference can then be used to perform additional operations depending on the nature of the control. Refer to the official SAP GuiScripting Help (delivered with the SAP Front End) for the complete list of public properties and operations.
Parameters
URI The Uniform Resource Identifier of the targeted object. For more information, refer to the URI syntax on page 14. 2010 SAP AG Page 136 of 147
Return value
A control as documented in the SAP GuiScripting Help.
Function ResolveParameterValue( Parameter ) The ResolveParameterValue function resolves the DT_ prefix (getting the actual value of the parameter from the DataTable) and interprets tokens.
Parameters
PARAMETER The Parameter parameter is the name of a column (String) in the DataTable or a string containing tokens (TAO Execution Context).
Return value
The resolved value (String).
Note
If the Parameter parameter has not or cannot be resolved it returns it unchanged (String).
Sub Report( Severity, Topic, Message, Options ) The Report procedure adds a step in the TAO Execution Report (ReportLog.xml).
Parameters
SEVERITY Possible values are:
TAO.INFO TAO.DONE TAO.PASSED TAO.WARNING TAO.FAILED
2010 SAP AG
TOPIC The Topic parameter is the step summary (String) MESSAGE The Message parameter is the step description (String) OPTIONS Reserved for future use
Sub Log( message ) The Log procedure logs in the debug file (DebugLog.txt).
Parameters
MESSAGE The Message parameter is a log entry (String).
Sub CaptureScreen() The subroutine does the equivalent of the CaptureScreen component. It takes a screenshot of the window of the current SAP GUI Session. The persisted screenshot will be visible in the SAP Test Acceleration and Optimization report. Default location for screenshot is <FF_ROOT_PATH>Logs\<TestName>\Images
Known Limitations
The screenshot capture is done using the Hardcopy method of the SAP GuiScripting API. This method does not work properly when the computer is locked, or the screen saver is running.
Sub Wait( milliseconds ) The Wait procedure stops the execution during a specified amount of time.
2010 SAP AG
Parameters
MILLISECONDS The Milliseconds parameter is the waiting time. The time is in milliseconds (Number).
Sub LoadLibrary( Library ) The LoadLibrary procedure loads the specified library.
Parameters
LIBRARY The Library parameter is the relative path, from the CBASE folder path, of the library to load.
2010 SAP AG
Advanced Concepts
Debugging the CBASE
VB Script language exception handling is poor and does not provide detailed information when an error occurs. For example, there is no way to dump the stack trace and it is difficult to find the root cause of a runtime error. This section explains how to set up a debug session in the HP QuickTest Professional environment.
Each SAP Test Acceleration and Optimization library can then be attached to the project: Choose the attach icon to select the library. Select the library in the appropriate folder. Check the FF_ROOT_PATH environment variable
Important
The CBASE_Bootstrap.vbs is the only library which is mandatory to enable the debug. You have to attach the CBASE_Bootstrap.vbs library. All other libraries are optional. Only attach the libraries that are relevant for the error you are troubleshooting.
2010 SAP AG
Proceed as follows: 1. 2. 3. 4. Run HP QuickTest Professional. Connect the HP QuickTest Professional to the SAP Quality Center server. Logon to the appropriate project Open the _SAP_Doc application area.
2010 SAP AG
Note:
Once the libraries are declared, save the changes. It might be necessary to stop and restart QuickTest Professional, to invalidate internal cached content and take into account the latest changes made in the Application Area.
2010 SAP AG
2010 SAP AG
The debugger tool provides common debugging features, like watching variables and expressions, as shown in this screenshot.
2010 SAP AG
Appendix
SAP GuiScripting Type
The table below shows the type of the SAP GUI objects, as they are displayed by the SAP GuiScripting API. GuiApplication GuiConnection GuiSession GuiFrameWindow GuiMainWindow GuiModalWindow GuiMessageWindow GuiLabel GuiTextField GuiCTextField GuiPasswordField GuiComboBox GuiOkCodeField GuiButton GuiRadioButton GuiCheckBox GuiStatusPane GuiCustomControl GuiContainerShell GuiBox GuiContainer GuiSimpleContainer GuiScrollContainer GuiListContainer GuiUserArea GuiSplitterContainer GuiTableControl GuiTableColumn GuiTableRow GuiTabStrip GuiTab 2010 SAP AG 10 11 12 20 21 22 23 30 31 32 33 34 35 40 41 42 43 50 51 62 70 71 72 73 74 75 80 81 82 90 91 SAP application SAP connection SAP session Not used Main window of the application Popup window Not used Label Text field Text field with F4 enabled Secure text field Combo box Ok Code Field - Used to start a transaction Button Radio button Check box Not used Not used Not used Not used Not used Not used Not used Not used Not used Not used Table control Used internally Used internally Tab strip (Parent Container of Tabs) Tab Page 146 of 147
GuiScrollbar GuiToolbar GuiTitlebar GuiStatusbar GuiMenu GuiMenubar GuiCollection GuiSessionInfo GuiShell GuiGOSShell GuiSplitterShell GuiDialogShell GuiDockShell GuiContextMenu GuiComponentCollection
100 101 102 103 110 111 120 121 122 123 124 125 126 127 128
Not used Not used Not used Status Bar - Used to retrieve transaction results Menu Not used Used internally Session Info - Used to retrieve current transaction Super class of all ALV Controls - Like GuiTree, GuiGridView Not used Not used Not used Not used Used internally Used internally
2010 SAP AG