1

It is possible to verify the text in image using sikuil plugin with java running on eclipse?

I'm testing a scenario where i double click on a saved notepad, i should able to verify that the notepad should not contain any blank text or the particular text is verified correctly.

Both 3a.png and 3b.png are not verified correctly. Any advise? 3a.png contains text "testing1" image 3b.png contains blank image

4.png contains black screen image - this verification was successful

// open notepad and insert text
pattern = new Pattern("C:\\Users\\User\\Downloads\\abc\\1.png");
            screen.doubleclick(pattern);
            screen.type("testing");
// close and save notepad
 pattern = new Pattern("C:\\Users\\User\\Downloads\\abc\\2a.png");
            screen.click(pattern);
 pattern = new Pattern("C:\\Users\\User\\Downloads\\abc\\2b.png");
            screen.click(pattern); 
           Thread.sleep(2000);
// open notepad with the text inputted("testing")
 pattern = new Pattern("C:\\Users\\User\\Downloads\\abc\\3.png");
            screen.doubleClick(pattern);
//verify image text -- did not verify properly. 3a and 3b images are printed correct. 
            if(screen.exists("C:\\Users\\User\\Downloads\\abc\\3a.png") != null ){
                //
                System.out.println("correct");
                }
            else
                System.out.println("wrong");
1

Use this link to know how to get proper reference image: Sikuli verification/assertion text image

After that you could use the below code to get the text from the region:

//find the image in the screen
Match c = screen.find(path);

//create a region with that image, means consider only that specific region where 
//the reference image is present
//c.getRect() gives the region coordinates of the image
Region r=new Region(c.getRect());

//now you can get text from that region using below command
System.out.println(r.text());
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.