Region.findText(): Finding text with Java API

Asked by Jeff Hall on 2018-01-22

I'm a little bit unclear on the status of the Region.findText() method in the SikuliX version 1.1.1 Java API.

There is documentation for this method:

...and it appears to be implemented in the Region class:

However, I noticed an answer (and related FAQ) that seems to indicate that the findText() method is not actually implemented:

I'm asking about the status because it doesn't seem to work as expected with my code, something like this:

public static boolean findTextInDocument(Screen s, String text) {
        boolean textFound = false;

        try {
            s.findText(text, 2000);
            textFound = true;
        } catch (FindFailed e) {

        return textFound;

Can anyone confirm that the findText() method should (or should not) work with the version 1.1.1 API?

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Solved by:
Jeff Hall
Last query:
Last reply:
RaiMan (raimund-hocke) said : #1

yes, works as it should (tested ;-)

--- because it doesn't seem to work as expected with my code
... what exactly?

Jeff Hall (oldjoe) said : #2

Thanks for the confirmation RaiMan!

The problem must be on my end. I keep getting a NullPointerException from the screen.findText() method in the following example class, but haven't been able to figure out why just yet...

public class DummyTest {

    private static Screen screen = new Screen();

    public static void setup() {
        Settings.OcrTextSearch = true;
        Settings.OcrTextRead = true;

        // Open Microsoft Word application
        screen.type(Key.ESC, Key.CTRL);

    public static void tearDown() {
        // Close Microsoft Word
        screen.type(Key.F4, Key.ALT);

    public void experimentWithText() {
        String text = "This is my favorite text string.";

        try {
        } catch (FindFailed findFailed) {



RaiMan (raimund-hocke) said : #3

Just tested on 1.1.2 --- works.

anything to see in the stack trace about the exception source?

Jeff Hall (oldjoe) said : #4

Aaagh, user error! Causing myself grief with typos.

Once I got that sorted out, the Region.findText() method is indeed working as described.

Thanks for your help RaiMan, and thanks for all your work on SikuliX.