how to accurately recognize text "Snapshot 1", "Snapshot 2"...

Asked by unixer

Hi,
There are some texts such as "Snapshot 1", "Snapshot 2", "Snapshot 3"... on a GUI.
Execute GUIRegion.hover("Snapshot 1"), then cursor always hover on text "Snapshot 2". Does anybody know how to improve the accuracy of text match like this?

Thanks.

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
Roman Podolyan (podolyan-roman) said :
#1

> Does anybody know how to improve the accuracy of text match like this?

If nothing else helps, read the manual.

http://sikuli.org/docx/globals.html
====
Settings.MinSimilarity

    The default minimum similiarty of find operations. While using a Region.find() operation, if only an image file is provided, Sikuli searches the region using a default minimum similarity of 0.7.
====

Try to tinker with it, setting it in script like

Settings.MinSimilarity = 0.95

Revision history for this message
Roman Podolyan (podolyan-roman) said :
#2

Oops, sorry, first I thought that you ask about graphic search.

Revision history for this message
RaiMan (raimund-hocke) said :
#3

If it does not work this way, then you should forget about the text feature using it this way (see bug 710586).

You might try to first findAll("Snapshot") and then loop through the matches and find out using Region.text().

Another general possibility is to select the text somehow and use type("c", KeyModifier.CTRL) to get it to the clipboard and the use Env.getClipboard() to compare it with a given text. this can be combined with the above findAll().

But when using the clipboard approach, you cannot use paste() in the same script currently (a bug).

Revision history for this message
unixer (p-unixer) said :
#4

Hi RaiMan,
Thanks for the answers. It is helpful. But sometimes region.text()'s output is not accurate. The text in the region is "Snapshot 88", but region.text()'s output is "Snapshot B8". Do you have any idea about how to workaround this?

And, you mentioned "select the text somehow". If the text can not be selected by Ctrl + A or mouse, then do we have any other choice to do this?

Thanks.

Revision history for this message
RaiMan (raimund-hocke) said :
#5

--- Do you have any idea about how to workaround this?
No, not with the current features of Sikuli.

--- If the text can not be selected by Ctrl + A or mouse, then do we have any other choice to do this?
sorry, no.
Depending on how the app is created and on what system you are, you need a tool, that can dig into the GUI elements like Selenium for HTML based web apps.
The magic word is "accessibility".

Can you help with this problem?

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

To post a message you must log in.