The functions SapGuiInvokeMethod, SapGuiSetProperty, and SapGuiGetProperty can be used to access the low-level properties of any control on the active screen. This makes it possible to, for example, confirm that a text control is read-only, or to determine the background color of a label.
The SAPGUI scripting API that is used for SAPGUI testing is a large COM library that allows Silk Performer to access controls and perform actions. This same COM library can be used with the above mentioned API calls. To access the list of methods and properties that individual controls offer, you must inspect the type library of the SAPGUI scripting API. For this you need a tool that facilitates the inspection of type libraries (for example the Ole32View tool that comes with Microsoft Visual Studio). With the tool, open the sapfewse.ocx file, which can be found in the SAPGUI installation directory under \FrontEnd\SapGui. The image below shows the properties that can be accessed on a label control:
To get the name of a control for which you know the control's ID, use the following call:
SapGuiGetProperty("/usr/lbl[1,2]", "Name", sOutValue); Print("The control has the following name:" + sOutValue);
Most properties return a simple data type such as a string, number, or boolean parameter. Some properties return other objects, for example the Parent property returns the parent control of the current control. When a property returns another control, the control is temporarily cached and can be accessed via the constant SAPGUI_ACTIVEOBJECT. Here is a code example for retrieving the name of a parent property:
SapGuiGetProperty("/usr/lbl[1,2]", "Parent"); SapGuiGetProperty(SAPGUI_ACTIVEOBJECT, "Name", sOutValue); Print("The parent control has the following name:" + sOutValue);
SAP introduced new properties and methods with its SAPGUI 640 client. With 640 you can, for example, get the background color of a label or checkbox. So, when you develop a script on 640 you must ensure that your agents also run on 640 and that the same patch level is used. Otherwise you may request properties that are not available on the agent and generate an error.
SAP is comprised of components that have the following properties (ComClass GuiComponent):
Visual components, such as controls, have additional properties (ComClass GuiVComponent):
Each control type may have additional properties which can be seen in the COM type library via your type library inspection tool.