SAP GUI Automation - Getting Started
abstract
This section details how to test SAP GUI Applications.
If you are not familiar with Sahi Pro, see Quick Tutorial on Sahi Pro
Start SAP GUI Automation
- Ensure that in userdata.properties,
sahi.sap.saplogon.execpath
specifies the correct path for SAP logon pad. - Scripting must be enabled for SAP GUI client.
- Open SAP GUI options from top right corner of SAP Logon pad.
- Go to Accessiblity & Scripting → Select Scripting.
- Check the Enable scripting checkbox under User Settings.
- sapgui/user_scripting must be TRUE to use scripting functions
- sapgui/user_scripting_disable_recording must be false if present. If it is TRUE then it is only possible to run scripts
- sapgui/user_scripting_force_notification must be false if present. If it is TRUE a notification is always displayed at the frontend
- sapgui/user_scripting_per_user must be false if present. If it is TRUE you need S_SCR authority to use scripting
- sapgui/user_scripting_set_readonly must be false if present. If it is TRUE it is not allowed to change the state of SAP GUI
- Start Sahi Dashboard
- Ensure
SAP Automation is enabled
i.eDisable SAP Automation
link is visible on Sahi dashbord. "Sahi SAP agent started!" message appears on Sahi Pro console.
Feb 19, 2020 2:48:30 PM net.sf.sahi.test.ProcessHelper execute INFO: cmd /C D:\Sahi_Pro\sap\bin\SahiSAP.exe -port=9999 > D:\Sahi_Pro\sap\SAP_log.txt >>>> Sahi SAP agent started! Feb 19, 2020 2:48:40 PM net.sf.sahi.test.ProcessHelper$PIDGatherer run INFO: PIDs: [8668]; 10491 ms
-
Enable scripting for SAP GUI client by following the steps below :-
info
-
Enable scripting for SAP GUI at server end by launching RZ11 transaction in SAP GUI and setting the following profile parameters :-
Using the Controller and Element Identification
- To Launch Sahi Controller, click the SAP icon on the Sahi Dashboard.
- On the Controller, go to the Record tab. The Controller can be used to interact with the SAP GUI application. User can Identify, Click, Set, Assert, choose Other Actions, or user can even Test an expression from Evaluate Expression to perform an action on the SAP GUI application.
- To identify an element, press the CTRL key, hover over any element.
Accessor:
shows the Sahi accessor for that elementAlternatives:
shows all alternative accessors for that elementValue:
shows the value of the current element. Mostly this is the input text or the visible text.Prefix:
window name.Mode:
shows the Automation mode
infoMake sure popup blockers are turned off.
info
- If SAP automation is not enabled,
Enable SAP Automation
link must be clicked from Sahi Dashboard before starting identification or recording. - Refer Identify Elements for a better understanding.
Evaluate Expression
Evaluating SAP GUI Application expression through Controller. It helps while identifying elements or while debugging.- Put a valid Sahi expression in the Evaluate Expression box
- Select mode as 'Sahi-SAP'
- Click on → The result will be seen in the bottom box.
Append
While recording, selecting and clicking onAppend
will append the steps to the currently recording script. This is mainly used for manually append any step from Evaluate Expression to the currently recording script.Highlight
Can be used on selected text to highlight the element (shows a red 1 pixel border briefly). Invokes the_highlight
API.Drop down
Lists some actions like Click, Get Value, Get Text etc.
infoNote: Selecting some text and pressing '→' will only evaluate the selected text.
infoNote: If SAP automation is not enabled,
Enable SAP Automation
link must be clicked from Sahi Dashboard and 'Sahi-SAP' must be selected as the 'Select mode for evaluate' during evaluating.infoRefer Evaluate Expression for a better understanding.
Recording a script
This is similar to recording a Sahi script for normal browser testing.- To record a script, launch the Controller, provide a script name and click 'Record'. Actions done on the SAP GUI client application are recorded automatically.
- Steps can also be recorded from the Controller.
-
A. You can use Click, Set, Assert, choose 'Other Actions' to perform an action on the SAP GUI client application.
B. You will need to record these steps explicitly by clicking on 'Append'.
info
- If SAP automation is not enabled,
Enable SAP Automation
link must be clicked from Sahi Dashboard before starting identification or recording. - Note : A user's interaction with SAP GUI involves communication with SAP server. A communication with SAP server is initiated by SAP GUI at multiple occasions. The most common actions by user that initiate SAP server communication are as follows:
- Enter key pressed from keyboard
- Click on Enter button in the toolbar
- Click on Save button in the toolbar
For example : When recording login operation, we would enter user name, enter password and press enter key from keyboard. In this case, all these three actions will be recorded after enter key is pressed. - Refer Record a script for a better understanding.
Playback
From Controller
Once a script is recorded, it can be played back from the Controller Playback tab itself.- Choose the script.
- Select Start Mode as
SAP
. - You can leave the Start url blank. This is not used for SAP GUI client application.
- Click on Play to playback the script.
- Click on Logs to view the logs of the played back script.
infoNote: A script cannot be played back if SAP automation is not enabled.
Enable SAP Automation
link must be clicked from Sahi Dashboard.infoRefer Playback Tab for a better understanding.
From the Editor
You can playback the script from the Editor as well.- Choose the script/suite/scenario from the Editor and click on the Playback button.
- Choose the Start Mode as SAP.
- Choose either of the two options - 'Run in single machine' or 'distributed (multiple machines)'.
- Press Run to playback the test.
infoNote: A script cannot be played back if SAP automation is not enabled.
Enable SAP Automation
link must be clicked from Sahi Dashboard.