questions on Text Recognition on the fly v3.0 Eggplant

I want to follow a link in a web Page that is rendered using Safari on Mac 10.3.3 . I am not able to use the Text Image Generation Option provided . If you can provide some examples it would be good

e.g recognize the link on this web Page which says “Forum Index” OR “Forum FAQ”

Recognize a Text on this web Page e.g “Post a new topic”

Recognize a Drop down option “Font Color” { Default /…/…}

What is the TextStyle that should be used . Do you support Custom types /What are the types you support

What should be the General approach of Text based Image recognition inside a Web Browser and Outside it .( i.e On any OS Native Window or outside)

Having Eggplant perform an action on text requires text images that match the text displayed by the test system. You can either capture these text images manually or you can have Eggplant generate these images for you during runtime.

If you are going to use Eggplant’s text generation capabilities to generate text images you need to specify the appropriate attributes for the text in question. A complete list of SenseTalk text attributes are as follows:

TextFont: font used for the text
TextSize: size of the text
TextColor: RGB color of the text
TextBackgroundColor: RGB color of the background
TextPlatform: The platform that you want to text to be generated on
Underline: Yes or No
Bold: Yes or No
Italic: Yes or No

Generating an image of the ?Forum Index? on this page could be done as follows:


MoveTo (Text:"Forum Index", TextFont: "Verdana", TextSize:"11", TextColor:(255,112,18))

Note: Any attribute NOTexplicitly stated will automatically assume the value stored in the default text style. The textBackgroundColor for instance, will assume the white background color stored in the default text style.

Text styles pertain to a set of specific text attributes. Menu styles and styles for window titles for instance, are specific text attributes that pertain to those particular interface elements. You can create your own text styles from Eggplant Preferences >> Text. Note: There are a handful of text styles already created for you. The ?Menu? text style for example, could be used to generate text images of menu items. Had you stored the text attributes for the example above into a style called ?redstoneLink? your script would read:


MoveTo(Text:?Forum Index?, TextStyle:?redstoneLink?)

Underlined Hyperlinks: Hyperlink underlines are typically NOT rendered through the font rasterizer but are drawn in as graphics making them very difficult to match with a generated underlined text image. Therefore, it is best if you do NOT use the underline property to generate hyperlink text that is underlined.

Hi EpJok ,
Thanks for your reply .
MoveTo (Text:“Forum Index”, TextFont: “Verdana”, TextSize:“11”, TextColor:(255,112,18))
works fine . But how do I know what is the font/size/style/color that I should try to get a match .Can i have a few guide lines to start with which would make this process easier

There was a previous discussion about this in another post.

http://www.redstonesoftware.com/phpBB2/viewtopic.php?t=365t=recognizing+text+attributes

I have thought of a script like this . Can you refine it/provide better suggestions


put "Files Terminal Network " into expTexts
put "Verdana Verdana-bold " into textFonts
repeat with redValText=0 to 255 step 1
	repeat with greenValText=0 to 255 step 1
		repeat with blueValText=0 to 255 step 1
			repeat with redValbgText=255 to 0 step -1
				repeat with greenValbgText=255 to 0 step -1
					repeat with blueValbgText=255 to 0 step -1
						repeat with each word of  textFonts
							put it into tmpFont
							repeat with TextSize=10 to 20 step 1
								repeat with each word of  expTexts
									put (redValText , greenValText , blueValText) into TColor
									put (redValbgText , greenValbgText , blueValbgText) into bgColor
									put  it &  Tcolor & bgColor & tmpFont
									if ImageFound(Text: it , TextSize: TextSize, TextColor: Tcolor , TextBackgroundColor : bgColor, TextFont:tmpFont )
										answer it &  Tcolor & bgColor & tmpFont
										
									end if
								end repeat
							end repeat
						end repeat
					end repeat
				end repeat
			end repeat
		end repeat
	end repeat
end repeat

Most of the text attributes can be determined by visual inspection. Colors on the other hand, can be determined using the color panel. Press command + shift + “c” to display the color panel while editing an existing script. Once you have the color panel displayed you can use the magnifying glass to determine what color a particular item of interest is in your remote window. Once you have the color determined you can drag the color from the color well (on the color panel) into your script. The R,G,B values should carry over into your script.

The only thing left to determine is the font and the size.


ask "Enter the Text to match"
put it into txtString

// make sure to update this property list with the appropriate colors and typeface appropriate to your situation
put (textBackgroundColor:(241,241,241), textColor:(0,0,0), underLine:"No", bold:"No", italic:"No") into style

// add some fonts to try out here
put ("LucidaGrande", "Monaco" ) into textFonts

repeat with font = each item in textFonts  
	repeat with tsize=10 to 20 step 1
		if ImageFound(0, (text: txtstring, textFont:font, textSize: tsize, textStyle:style)) 
			answer "Font:" && font & return &  "Size:" && tsize
			exit all
		end if 
	end repeat 
end repeat 

If you really want to be clever you can construct a search rectangle of the remote screen that defines the region that contains the text (txtString).

The Image search works but I am not able to Click Buttons or Links which I was able to do with the Image Capture Technique used in Eggplant versions < 3.0

I get a number of false results where it says the Text is Present even if it is not present .e.g If there is a sign in button having the Text “Sign In” and I give “Sign In4444” there is a match


ask "Enter the Text to match" 
put it into txtString 

// make sure to update this property list with the appropriate colors and typeface appropriate to your situation 
put (textBackgroundColor:(241,241,241), textColor:(0,0,0), underLine:"No", bold:"No", italic:"No") into style 

// add some fonts to try out here 
put ("LucidaGrande", "Monaco" ) into textFonts 

repeat with font = each item in textFonts  
   repeat with tsize=10 to 20 step 1 
      if ImageFound(0, (text: txtstring, textFont:font, textSize: tsize, textStyle:style)) 
             Click (text: txtstring, textFont:font, textSize: tsize, textStyle:style) // [B]This does not click[/B]
         answer "Font:" && font & return &  "Size:" && tsize 
         exit all 
      end if 
   end repeat 
end repeat