Unable to get TextImage. No TextFont specified

I have defined a text style in Eggplant Text Preferences, with the exact value of font, size, and the colors. I used this style to detect a text like this:
Click (TextL"my text", TextStyle:“NewStyle”)

I then ran my script and I encountered this error:
Unable to get TextImage. No TextFont specified

I checked from Eggplant Text Preferences that the style that I defined previously indeed has the correct value of font, size and colors. I’m wondering why Eggplant complaint about this error?

I am trying to print the properties of NewStyle, is it possible to do through scripting? Please advice. Thanks.

Ai Choo

We have seen an occasional bug where defined styles aren’t saved properly from the Text Preferences; make sure you are running the latest Eggplant and try generating that text style again.

To view the text styles in Eggplant you can set the currentTextPlatform and then use a line line this.

put styles of the currentTextPlatform

This problem happens to me on Vista platform. Eggplant managed to detect the text if it is using the native Vista font (which is Segoe UI in this case). However, Eggplant is unable to detect the text if it is using Microsoft Sans Serif.

The version that we are using now is 4.1 (1120). I tried to remove the existing text style and redefine it, but it didnt help to resolve the problem.

In the event where Eggplant said that the text image is not found, I’ve to put all the attributes of the related text in order to make it works properly. See code below:

Click (Text:"my text", TextStyle:"NewStyle", TextFont:font, TextSize:8, Bold:"Yes", TextBackgroundColor:Color1, TextColor:Color2) 

Instead of putting a long list of text properties each time when I use it, I’m thinking of whether there is a way to define this text style in script other than through Eggplant Text Preferences. I’m hoping to define the text styles at the beginning of my script, then use them repeatedly in other scripts.

Please advice. Thanks

Yes, you can define text styles (and even whole text platforms) very easily directly in your script. Often it’s simpler to define them in the Text Preferences and just select them in your script, but sometimes it makes sense to create styles in your script.

If you want to define a style in your script, you can do it like this:

set the currentTextPlatform.styles.NewStyle to (TextFont:font, TextSize:8, Bold:"Yes", TextBackgroundColor:Color1, TextColor:Color2)

That will define a style called “NewStyle” that you can use subsequently in any script during that run.

click (Text:"my text", textStyle:"NewStyle")

All of the text styles for all of the defined text platforms are contained in a global property called the textPlatforms (try typing “put the textPlatforms” in the Do box to see it all). You can modify the styles through the textPlatforms, but it’s a large and complex structure, so the currentTextPlatform is designed to provide a shortcut to the current platform that you can use as shown above.

Keep in mind that generally, if you are working with two different platforms (such as Windows XP and Windows Vista) you should probably define two text platforms, with corresponding styles in each. Then you can set the currentTextPlatform to the one you’re working with and each style will be correct for that platform.