In some cases, if a controls element in the tested application has not been completely recognizable (for example, nonstandard toolbar), TestComplete can still provide us with access to some of the private properties of the element in view using the text recognition method.
In this recipe, we will consider usage of the text recognition method for accessing buttons on the toolbars in Paint application.
Launch a standard Paint Windows application (navigate to Start | All programs | Accessories | Paint).
In order to recognize text from controls we need to perform the following steps:
Sys.Process("mspaint").Window("MSPaintApp", "Untitled - Paint", 1).Window("UIRibbonCommandBarDock", "UIRibbonDockTop", 3).Window("UIRibbonCommandBar", "Ribbon", 1).Window("UIRibbonWorkPane", "Ribbon", 1).Window("NUIPane", "", 1).Window("NetUIHWND", "", 1).
NetUIHWND
to the list of List of accepted windows.If a nonstandard controls element uses a standard Windows API for text output, we could recognize the text within it with the help of Text Recognition method, as described.
With the elements of the TextObject
type we can make ordinary actions (for example, triggering mouse-clicks on them, obtaining values of the properties, and so on); however, having no possibility to normally work with their parent objects. For example, in case of the Select button in Paint, we are getting access only to the text Select
, and not to all the buttons with image. Nonetheless, these simple possibilities are usually sufficient for functional testing.
3.140.196.244