How to validate a particular value, whether it is displayed on a page or not.

Asked by Atul Desai

I am automating an application where I set a value to a textfield and save it(from Admin side). Now when i login with user this value is displayed on welcome page. I have to verify whether the value is getting reflected at user end or no?. Can you help me and suggest an approach by which i will be able to catch this text on welcome screen.

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
Vyacheslav Kolesnik (uzb310) said :
#1

Probably you need use OCR features to make pictures identification against your value

Revision history for this message
Eugene S (shragovich) said :
#2

Hi,

Theoretically you have 2 options:
1. Using OCR features (as suggested in the previous post). You can try to use the built in OCR features to try and detect the value on the screen. Basic usage looks something like this:

Settings.OcrTextRead = True
value = find("value")

But here you have to keep in mind few things. First, as with any OCR, you have to make sure that the value you are looking on the screen appears only once. For example if that's a certain number you are looking for, make sure that similar number does not appear somewhere else on the screen. If there is a chance of that to happen, you will have to define a limited area to look for the value. For example, something like that:

region = find("pattern.png")
value = Region.text()

Second, the built-in OCR features are not 100% reliable and the result depends very much on the text size and font. If that's just a regular, small characters (for example like here), chances that it will be recognized properly are very low. Here comes the second option.

2. Using copy / paste
For the reasons explained above, it might be a better idea to copy the text to clipboard rather than try to detect it using the OCR features. To do that, you will have to select the text (double click on it for example) and then copy it (Ctrl + C).

type("c", KEY_CTRL)

Then to access the text, you can get it from the clipboard like that:

value = Env.getClipboard()

See which way suits you most.

Cheers,
Eugene
When

Revision history for this message
Atul Desai (atuld) said :
#3

Thank you Eugen, the issue is resolved by using

region = find("pattern.png")
value = Region.text()

Can you help with this problem?

Provide an answer of your own, or ask Atul Desai for more information if necessary.

To post a message you must log in.