SAP Netweaver - Dynamic ID's
This article provides you with the best practice how to steer dynamic ID's in SAP Web Interface, such as SAP Netweaver, SAP Business Client and SAP FIORI.
Situation
It is known, that the object IDs in SAP Netweaver (SAP Webinterface, SAP WebGUI) are generated dynamically everytime an object/element is displayed. This could be a headache for test automation tools and stability of the test cases.
Solution
With Tosca we are not only able to identify controls based on technical ids, but we can also use other techniques.
Solution 1: Object identification by more than one properties (Identify by Properties)
- Scan the required test object by using Tosca XScan.
- Deselect the dynamic ID (red box)
- Choose another control type (one or more), which is more suitable for stable identification of this object type.
For example, Tag and Title are good options (green box). "Sales Organization" will be uniquely identified and is stable for test case creation and execution.
Solution 2: Object identification by anchor (Identify by Anchor)
-
Scan the required test object by using Tosca XScan.
-
Open the Identify by Anchor window by clicking on the corresponding button in the HOME menu.
-
Select the control which should be identified.
-
Use drag and drop to move the control, whose identification criteria should be copied, to the Anchor Control field. The control is shown in this field as soon as you release the mouse button.
The Anchor Control Properties field shows the properties that were transferred along with the control.
Solution 3: Object identification by index (Identify by Index)
This option shows or hides the Identify by Index window. If a selected control does not have a unique ID, you can select an index to be used upon test execution to identify the control. Enable the checkbox next to Index to select the index. The index is calculated dynamically and on the basis of already selected identification criteria.
Solution 4: Parent Control object identification
If the control is unique only in a specific area (e.g. within one container), then this container could be used as a parent control for unique control identification. In this case the entire path/tree should be chosen too for the identification.
Picture 01: control is not unique
Picture 02: control is unique in a specific area (table container)
Solution 5: Identify by Image
Tosca is able to identify controls from an image by creating a screenshot for a specific control. For further information, please see also the Tosca Manual.
With that approach we were able to successfully finish all our customer projects.
Reference
Alex Brandenberger
Tip 1 and 4 - or a combination of both - have always solved my issues so far. On the matter of what properties you want to use - take the most stable ones and try to use as little "material" as possible to identify. Thus a general guideline from my experience, sorted by likelyhood of the property to change over time.
1. Classname/Default/Name etc. (Object-bound)
2. InnerText/Placeholder etc. (Content-bound)
3. Innerhtml/Index etc. (Application-bound)
This is only a general overall guideline and depends much more on the kind of application you are testing then on what properties are available.
Holger Wasilewski
I have experienced that a combination of parental adressing, and masking dynamic parts of IDs helps - i have seen often ids which contain a name of the programmed data object and a dynamic part. Using a "*" to mask the dynamic part helps and works fine.