Have you encountered a situation where your Application Under Test (AUT) seems to be compatible with UFT except for a few controls? What have you done to fix the issue? Low level recording? Web Extensibility? There is another reliable mechanism in UFT which can be used when the object is not supported by the tool. It is known as UFT Insight.
Guide to Micro Focus UFT Insight

What is UFT Insight?

Insight is a technique in UFT that allows image based object recognition rather than properties based object recognition.

UFT – normally – identifies objects using a set of properties for a given test object class, as also discussed in the complete object identification process in UFT. There are situations where UFT may not be able to identify an object in a given AUT using regular process. HP (now Micro Focus) introduced Insight in UFT 11.5. UFT Insight allows image-based object recognition, which allows UFT to recognize and record any object in a given application, irrespective of the tool used to build it.

With Insight, UFT stores an image of the object with the Insight test object (along with ordinal identifiers, if necessary.), and uses this image as the main description property to identify the object in the application. Insight test object does not make use of mandatory/assistive properties or smart identification.

How to add Insight object?

You can add Insight objects using Insight recording or from the object repository.

1. Insight Recording

Insight object can be added on any AUT. Once you press the Record button , Insight Recording appears under the Record menu and recording tool bar.

Add UFT insight object during recording

2. Add Insight object from Object Repository

From inside an object repository you can add Insight objects by going to Object > Add Insight Object to Local or by clicking the toolbar button.

add insight object using object repository UFT will prompt you to choose automatic or manual learning mode.

insight-learn-mode

Automatic learning mode enables you to point and click on the object while Manual learning mode allows you to manually specify the borders of the control you wish to learn. In our tests, we found Automatic mode was pretty accurate.

UFT Insight Demo

Let us understand UFT Insight by recording on the calculator app available in Windows 10. We will launch the Windows 10 Calculator app. Click the record button in UFT and click Insight Recording.

This is how the recorded script would look like.

insight-script-uft

The simple script above shows that we have clicked on the calculator icon in tray and then successively clicked the numbers 2,0,1,9 on the Windows 10 calculator. The calculator icon and all the numbers  are captured as Insight Objects.

How to Edit an Insight Object?

If the intended image is not captured properly or is not centered, you can double click on the image in the editor. It will take you to the object repository where you can edit the image.

Illustration below is shown for the number 1. UFT has captured 1  2  3 in a single capture while we just want 1 in the capture. Check the graphic below on how to edit an Insight object.

editing insight object UFT

Various UFT Insight options are available under Under Tools > Options > GUI Testing > Insight.

uft-insight-options

You can choose to show test object image in steps. By default this option is enabled. Unless the image size is too large, we prefer to keep this enabled otherwise UFT produces counterintuitive names for insight objects as shown below.

insight-object-name-when-show-image-is-disabled

When we ran the script, we found a high degree of accuracy in identifying Insight object and UFT successfully clicked on the numbers in every run.

When to use UFT Insight while testing?

UFT insight can be most beneficial in situations where few controls in your AUT are not recognizable by normal object identification means in UFT.

Insight also allows you to do operations on the Insight object. You can use GetVisibleText method to extract the text from the Insight object.

Here is a one line script to extract the number shown on the captured object.

Use GetVisibleText on insight

UFT internally uses Optical Character Recognition (OCR) mechanism to extract text from an insight object. From performance point of view, OCR is a slow process. Keep this in mind when you choose to use GetVisibleText method on an Insight object.

How to use Insight in Descriptive Programming (DP)?

UFT provides ImgSrc property to use in an Insight object in Descriptive Programming. Inline method of DP uses “property:=value” pair. In case of Insight object, property can be ImgSrc with values as the image location on a file system (or an ALM path). You can also optionally use index or location ordinal identifiers or similarity as one of the properties in an Insight object.

Here is an example of using ImgSrc in DP.

Window("Calculator").InsightObject("ImgSrc:=C:\UFTFiles\number1.png").Click

Important points to note while using Insight with Descriptive Programming.

  1. The image file should be accessible from the machine that runs the test. The file location can be either the local machine or ALM. It can not be a random site on the internet.
  2. The file must be a non-compressed image file that supports 24/32 bits per pixel and can have an file name extension of jpeg, bmp or png
  3. The ImgSrc property is mandatory.
  4. You can optionally use ordinal identifiers like index or location.
  5. You can optionally use similarity property with possible values ranging from 1-100. Similarity property specifies in percentage how similar a control in the application has to be to the test object image for it to be considered a match. The default value is 80.
  6. The ImgSrc property does not support regular expressions.
  7. The Click method would click in the center of the image when you use Descriptive Programming on an Insight object.

Best Practices with UFT Insight

  1. Record and replay of UFT insight scripts is limited to primary monitor.
  2. Ensure the machine resolution and browser zoom is the same across all machines where Insight script is run.
  3. Once you are done with Insight object configuration to your satisfaction, delete the redundant images captured by UFT by going to object repository > Tools > Delete Insight Snapshots. This may improve the performance of your tests.

Fun with Insight

Here is a YouTuber Roee Weisbert playing Angry birds using UFT Insight. The video goes on to prove that Insight is pretty accurate for what it does.