Teaching Fonts to WinRunner - WinRunner

In most cases, WinRunner can identify the text on GUI objects automatically. However, if you try to read text and the comment “#no text was found” is inserted into the test script, this means WinRunner was unable to identify your application font.

To enable WinRunner to identify text, you must teach WinRunner your application fonts using the Fonts Expert Utility and use the image text recognition mechanism when running your tests.

To teach fonts to WinRunner, you perform the following main steps:

  1. Use the Fonts Expert tool to have WinRunner learn the set of characters (fonts) used by your application.
  2. Create a font group that contains one or more fonts.

A font group is a collection of fonts that are bound together for specific testing purposes. Note that at any time, only one font group may be active in WinRunner. In order for a learned font to be recognized, it must belong to the active font group. However, a learned font can be assigned to multiple font groups.

  1. In the Record > Text Recognition category of the General Options dialog box, select the Use image-based text recognition option and enter the font group you created in the Font group box.
  2. Use the TSL setvar function to activate the appropriate font group before using any of the text functions.

Note that all learned fonts and defined font groups are stored in a font library. This library is designated by the XR_GLOB_FONT_LIB parameter in the wrun.ini file; by default, it is located in the WinRunner installation folder/fonts subfolder.

Learning a Font

If WinRunner cannot read the text in your application, use the Font Expert to learn the font.

To learn a font:

  1. Choose Tools > Fonts Expert or choose Start > Programs > WinRunner > Fonts Expert. The Fonts Expert window opens.
  2. Choose Font > Learn. The Learn Font dialog box opens.
  3. To learn a font

  4. Type in a name for the new font in the Font Name box (maximum of eight characters, no extension).
  5. Click Select Font. The Font dialog box opens.
  6. Choose the font name, style, and size on the appropriate lists.
  7. Click OK.
  8. Click Learn Font.
  9. When the learning process is complete, the Existing Characters box displays all characters learned and the Properties box displays the properties of the fonts learned. WinRunner creates a file called font_name.mfn containing the learned font data and stores it in the font library.

  10. Click Close.

Creating a Font Group

Once a font is learned, you must assign it to a font group. Note that the same font can be assigned to more than one font group.

To create a new font group:

  1. In the Fonts Expert window, choose Font > Groups. The Font Groups dialog box opens.
  2. To create a new font group

  3. Type in a unique name in the Group Name box (up to eight characters, no extension).
  4. In the Fonts in Library list, select the name of the font to include in the font group.
  5. Click New. WinRunner creates the new font group. When the process is complete, the font appear in the Fonts in Group list.

WinRunner creates a file called group_name.grp containing the font group data and stores it in the font library.

To add fonts to an existing font group:

  1. In the Fonts Expert window, choose Font > Groups. The Font Groups dialog box opens.
  2. Select the desired font group from the Group Name list.
  3. In the Fonts in Library list, click the name of the font to add.
  4. Click Add.

To delete a font from a font group:

  1. In the Fonts Expert window, choose Font > Groups. The Font Groups dialog box opens.
  2. Select the desired font group from the Group Name list.
  3. In the Fonts in Group list, click the name of the font to delete.
  4. Click Delete.

Running Tests on Learned Fonts

In order to instruct WinRunner to use the fonts in your font group, you must use the Image Text Recognition mechanism instead of WinRunner’s standard text recognition mechanism and you must activate the font group that includes the fonts your application uses.

To enable WinRunner to recognize learned fonts:

  1. Choose Tools > General Options. The General Options dialog box opens.
  2. Choose the Record > Text Recognition category.
  3. To enable WinRunner to recognize learned fonts

  4. Select Use image-based text recognition.
  5. In the Font group box, enter a font group.
  6. Click OK to save your selection and close the dialog box.

Only one group can be active at any time. By default, this is the group designated by the XR_FONT_GROUP system parameter in the wrun.ini file. However, within a test script you can activate a different font group or the setvar function together with the fontgrp test option.

For example, to activate the font group named editor from within a test script, add the following statement to your script:

setvar ("fontgrp", "editor");

For more information about setting text recognition preferences from the General Options dialog box, see “Setting Global Testing Options.” For more information about using the setvar function to choose a font group from within a test script, see “Setting Testing Options from a Test Script.”


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

WinRunner Topics