In rare cases, Ranorex Studio cannot identify UI elements of an AUT (application under test) correctly. This can happen with certain legacy technologies such as VB6, MFC, and older Delphi versions. In these cases, you can use the GDI (Graphics Device Interface) capture feature to improve UI element identification in Ranorex Spy.
Ranorex Studio supports both GDI and GDI+. GDI+ recognition is turned off by default and must be enabled manually (explained at the end of this article).
The GDI capture feature is part of Ranorex Spy and is accessed from an element’s context menu in the element tree browser.
Use GDI capture when tracking/identification selects a large container (for example, an entire control) instead of the specific UI element you clicked (common in GDI-based UIs).
Non-GDI UI-element identification
This example uses the calendar in the Ranorex Studio Demo Application. The goal is to identify the UI element for a specific day of the month.
- Start Ranorex Spy and click TRACK.
- In the Demo Application, click a specific day, for example, January 16.
Result
- The RanoreXPath shows that the entire calendar (not a specific day) was identified.
- In the element tree, the UI element has the adapter type DateTime (for example, a calendar).
- The screenshot for the UI element shows the entire calendar, not just the selected day.
Enable GDI capture
Since default identification didn’t work, enable GDI capture by adding the incorrectly identified UI element to the GDI capture list. In this scenario, Ranorex can locate the correct UI element based on the RawText adapter class.
- In the element tree, select the UI element you want to be handled by GDI capture.
- Right-click it and click Add class name to GDI capture list.
- Click OK to confirm the info dialog.
Now, you can track the UI element once more.
- Click TRACK.
- Click a specific day in the calendar, for example, January 16.
Result
The UI element is identified correctly based on the RawText adapter.
- The RanoreXPath shows the date of a specific day, and not the entire calendar.
- In the element tree, the UI element has the adapter type RawText.
- The screenshot shows the UI element for the specific day instead of the entire calendar.
Add a process to the GDI capture list
It is recommended to add single UI element classes to the GDI capture list. If you need to add an entire process (for example, for backward compatibility), do it via GDI capture settings (next section).
GDI capture settings
The GDI capture settings display all added processes and class names. This is also where you can add entries in bulk or by specifying a regular expression. You can access GDI capture settings from the Settings dialog in Ranorex Studio or Spy.
- Click SETTINGS….
- In the General tab, click GDI capture settings….
- The GDI settings open.
Enable GDI+
GDI+ recognition is turned off by default. If required, enable it manually under Settings > Plugins > Capture GDI+ text.