Testing SAP GUI

Applies to TestComplete 14.92, last modified on September 16, 2021

SAP ERP is a resource-planning 3-layer solution by SAP SE for managing business processes. Three layers of the solution include the database, application server, and client (SAP GUI or SAP Front-End). SAP GUI allows accessing SAP solution features. There are versions for Windows, Linux, and Apple. With TestComplete, you can create and run automated tests for the SAP GUI for Windows.

Supported SAP GUI versions

SAP GUI 7.40 - 7.70 for Windows.

Requirements and prerequisites

  • TestComplete version 14.74

  • An active license for the TestComplete Desktop module.

  • The Desktop Testing and SAP Support plugins must be enabled in TestComplete (they are installed and enabled by default).

  • SAP GUI Scripting API must be enabled (see below).

Preparing SAP GUI for testing

For TestComplete to be able to access SAP GUI internals and simulate user actions over it, the scripting must be enabled in SAP GUI. You can do it on the server side or on the client side:

On client side
  1. Launch SAP Logon and click Options.

  2. In the tree on the left, select Accessibility and Scripting > Scripting.

  3. Make sure that Installation is set to Scripting is installed.

  4. In the User Settings section, select the Enable scripting check box.

  5. Disable the rest of the check boxes.

    Enabling scripting in SAP GUI

    Click the image to enlarge it.

  6. Apply and save the changes.

On server side

Set the sapgui/user_scripting parameter to true:

  1. Launch SAP Logon and connect to your SAP server.

  2. In the Transaction text box, enter RZ11.

  3. In the resulting Profile parameter maintenance dialog, enter sapgui/user_scripting and click Display.

  4. In the Display Profile Parameter Attributes dialog, click Change Value.

  5. In the Change Parameter Value dialog, in the New Value text box, enter True and click Save.

  6. You may need to re-log on for the changes to take effect.

You may also need to enable scripting for a user profile:

  1. In the Transaction text box, enter RZ11.

  2. In the resulting dialog, locate the sapgui/user_scripting_per_user parameter and click Display.

  3. In the resulting dialog, click Change Value.

  4. Set the parameter value to True and then click Save.

Creating and recording tests for SAP GUI

To create a test, you can record your user actions in SAP GUI or you can create a test from scratch. The easiest way to create a test is to record it:

  1. Start recording.

  2. Launch SAP GUI for Windows.

  3. Interact with the application as an end-user would: click buttons, input data into forms, and so on.

  4. Stop the test recording.

TestComplete will process the performed actions and generate the test. The images below show an example of a recorded test:

A keyword test

A keyword test recorded for SAP GUI

Click the image to enlarge it.

A script test

A script test recorded for SAP GUI

Click the image to enlarge it.

A test consists of the sequence of operations that define various interactions with objects in SAP GUI.

Currently, there are several issues you may encounter when recording automated tests for SAP GUI. See below.

Depending on the Tools > Options > Engines > Name Mapping > Map object names automatically option, the recorded test will use custom (mapped) names to locate objects in SAP GUI.

You can modify and enhance the recorded test to make it more flexible and efficient. For example:

  • Add new operations, reorder them, and modify their parameters.

  • Delete or disable unneeded operations (for example, superfluous recorded operations).

  • Insert checkpoints for verifying objects and values in the tested application.

  • Create data-driven tests that run multiple test iterations using different sets of data.

What automated tests can do

Tests you create for SAP GUI can:

  • Simulate basic user actions over GUI elements: click buttons and menu items, enter text into edit forms, and so on.

  • Verify the state of objects.

  • Access internal properties of objects.

About SAP GUI object identification and Name Mapping

TestComplete recognizes individual controls in SAP GUI and can access their internal properties. In tests, you simulate user actions over SAP GUI by interacting with these controls rather than by simulating clicks and mouse movements using screen coordinates.

Exploring SAP GUI object hierarchy

To view SAP GUI objects that you can access from your tests, as well as their properties and methods you can use to simulate user actions, you can use the Object Browser or Object Spy.

Exploring SAP GUI in the Object Browser

Click the image to enlarge it.

Note: SAP GUI must be running and be prepared for testing as described above.

Available properties and methods include both native ones (provided by SAP scripting API) and those provided by TestComplete.

Controls in SAP GUI can have dynamic identifiers that vary between application sessions. TestComplete can detect such dynamic identifiers and generate identification properties that ignore the dynamic parts. Such identification properties will remain valid and the tests will be able to locate the tested control correctly.

About support for SAP GUI controls

TestComplete automatically recognizes individual controls in SAP GUI by their type and lets you interact with them both at design time and during test playback. In addition, TestComplete provides extra properties and methods for several controls in SAP GUI. These extra properties and methods are used for automating various interactions with controls. For example:

  • Clicking a button is recorded and played back by using the ClickButton operation.

  • Typing text in a text field is recorded by using the SetText operation.

For the list of SAP GUI controls for which extra support is provided, see:

List of SAP GUI Controls

Note: Currently, TestComplete does not support recording extra methods for these controls. You can only use them when creating tests manually.

Automating unsupported controls

Your tests can simulate user actions over unsupported controls by using properties and methods TestComplete provides to onscreen objects. Interactions with these controls are typically recorded as coordinate-based clicks. You can also automate these controls by calling their native methods from your test.

Name Mapping

To interact with controls, your tests must first locate the needed control in SAP GUI. The easiest way to do it is to add the control to the Name Mapping repository of your TestComplete project. For each object, the repository stores the custom (mapped) name used to refer to the control from tests and a collection of identification criteria — the control’s properties with their values.

When you record a test, TestComplete captures all windows and controls of SAP GUI which you are interacting with and adds them to the Name Mapping repository automatically. You can also add objects to the repository manually.

The image below shows an object in SAP GUI added to the Name Mapping repository:

SAP GUI element added to the Name Mapping repository

Click the image to enlarge it.

You can modify the mapped names assigned to objects and their identification criteria.

Adding SAP GUI to Tested Applications collection

You may want to add SAP GUI to the list of tested applications of your TestComplete project to access and launch it faster and easier.

Automatic

By default, when you launch SAP GUI during the test recording, TestComplete will add the executable to the list of tested applications automatically and add commands that launch the application to the recorded test.

Recorded Run TestedApp operation that launches SAP GUI

Click the image to enlarge it.

Manual

You can add SAP GUI executable to the Tested Applications collection from the TestComplete IDE.

View instructions

Launching SAP GUI from tests
From keyword tests

To run SAP GUI from a keyword test, use the Run TestedApp operation:

Running SAP GUI from a keyword test

Click the image to enlarge it.

From scripts

To run a tested application, call the TestedApps.TestedApp_Name.Run method. For example:

JavaScript, JScript

TestedApps.saplogon.Run();

Python

TestedApps.saplogon.Run()

VBScript

TestedApps.saplogon.Run

DelphiScript

TestedApps.saplogon.Run;

C++Script, C#Script

TestedApps["saplogon"]["Run"]();

Access native methods and properties of SAP GUI objects in tests

TestComplete can access properties and methods provided by the SAP Scripting API, and you can use them in your tests, for example, to check the tested object state or simulate user actions over the object. You can view those properties and methods in the Object Browser and Object Spy:

  • On the Fields tabbed page.

  • In the SAP category on the Methods tabbed page.

Access native properties and methods in SAP GUI

Click the image to enlarge it.

Known issues and limitations

  • TestComplete does not support recording user actions over status bar items.

  • TestComplete always records entering text as the Keys method instead of assigning a new text value to the appropriate controls.

  • When recording entering text, TestComplete may fail to record all pressed keys correctly.

  • TestComplete may fail to record double-clicks.

  • TestComplete may fail to recognize text box, check box and button controls during test recording and record user actions over them as coordinate-based actions or OCR-based actions instead of proper methods.

  • TestComplete may fail to recognize modal windows and dialogs and fail to record user actions over them or record user actions over them incorrectly or record user actions over them as coordinate-based clicks.

  • TestComplete may fail to record user actions over menu items.

See Also

Testing Enterprise Applications

Highlight search results