Able to see custom data?

Asked by William Elmer

I am developing a app that will test a I-series product.
currently, I have it reading a password and a user from a script and then going into a document. This document has already been filled out and the test I want to verify is that the data has been inserted correctly(writing regression tests) so for example

Name: file.readline();
type(Name)
Exists(screenshot)

the screenshot should look for Name label and to the right of it find John. But if "John" were to change his name to lets say Paul is the only way to edit the script to update the screenshot?

any suggestions would be great!

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
j (j-the-k) said :
#1

There are two alternatives to updating the screenshots:

1.
Try to use OCR(Optical Character Recognition):
For this you need a Region that contains the name and if possible only the name and no other text.
Then you can do this:
# create Region that contains only the desired name, how you do this depends on your GUI.
region = Region(x,y,w,h)
# extract the text with OCR and remove leading and trailing whitespaces
name = region.text().strip()
# check the name
if (name = "John"):
    #do john stuff
elif(name = "Paul"):
    #do paul stuff

OCR can be very good or useless, depending on your font, fontsize and language, you'll have to try.

2. If the name in the GUI can be selected(highlighted), you can use this for the following:
# find Position of the name by using a nearby key image and doubleclick on the name to select the word (doubleclicking on a word usually selects the whole word)
doubleclick("keyimage.png").targetOffset(x,y)
# copy name to clipboard
type("c",KEY_CTRL)
# get the name and remove leading and trailing whitespaces
name = Env.getClipboard().strip()
# check the name
if (name = "John"):
    #do john stuff
elif(name = "Paul"):
    #do paul stuff

I hope one of this methods works for you

Can you help with this problem?

Provide an answer of your own, or ask William Elmer for more information if necessary.

To post a message you must log in.