Compare existing value from capture image

How do I compare a value that is already displayed in a field? I want to compare the value that is 5.58. I don’t need to re-type it only if the data has different number. For example:

 Data Field:  5.58

Here is my script su-do code:

If Imagefound(“data field”) then
compare the vaule
if the value is true then
log the date value is 5.58
else
log the data value is not 5.58
and change the value
end if
end if

Thanks,

If the text that you want to compare is in an editable text field or is otherwise selectable, then you can copy it to the clipboard on the SUT and then pull that value into your script. Here’s some sample code for what that might look like:

Click "myTextField"
typeText commandkey, "a"
TypeText commandkey, "c"
put RemoteClipboard() into testVal
if testVal is not equal to "5.58"
	logError "field is displaying wrong value:" && testVal
end if

Another approach would be to use the text-image generation feature to create a text image of the value that you are looking for. This requires that you know the font properties (face, size, etc.) used to display the text. This would look something like this:

if not imageFound((Text:"5.58", TextFont:"Helvetica", TextSize:"10"))
	logError "Incorrect value displayed"
end if

Note that this command could use a variable in place of the hard-coded text string so that you could iterate through many values:

if not imageFound((Text:myStringVar, TextFont:"Helvetica", TextSize:"10"))
	logError myStringVar && "not found"
end if