Diff Between find and Exists and which method is efficient

Asked by Maniraj on 2017-11-30

Pattern Endicon = new Pattern("/Users/raj/Desktop/Sikuli/23.png");
 public static boolean iconverify(Pattern icon)
                // if(screen.find(icon.exact()) != null)
  if(screen.exists(icon.exact())!= null)
   System.out.println(icon+"Icon verified");
   return true;
  System.out.println("Icon Not verified");
  return false;

Which one is efficient

While using find Keyword Script execution getting stop but while using Exists it is not happening.. Help to make this above Method more efficient

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:

This question was reopened

RaiMan (raimund-hocke) said : #1

find() throws exception, which must be catched for decisions how to proceed.
exists() returns null or a Match object and as such can be used as in your example.

Maniraj (aathimaniraj) said : #2

Thanks RaiMan, that solved my question.

Maniraj (aathimaniraj) said : #3

I am Trying to Select region but it select region in Desktop not on my screen which i need to test, Kindly guide me to reslove this issue

RaiMan (raimund-hocke) said : #4

read the docs:

Multi-Monitor Environments

Maniraj (aathimaniraj) said : #5


I do not how to switch to opened window it is refer Desktop screen of my laptop and taking Screenshot i need to take screenshot in the window which is opened by Selenium
Note: i am using MAC Laptop

                WebDriver driver2=new ChromeDriver();
  WebDriverWait wait2 = new WebDriverWait(driver2, 40);

                Region reg = new Region(413,248,680,510);

Kindly help me and share code if possible to focus the region in the website which opened by selenium web driver.

RaiMan (raimund-hocke) said : #6

How many monitors are attached to your system including that where the desktop is displayed?

Maniraj (aathimaniraj) said : #7

including monitor 3 and if i am set region and trying to click icon which is out that region but it is visible in that page it seld, weather sikuli will click image or not.

Using sikuli 1.1.1

IF possible share some codes to explain region in java.

RaiMan (raimund-hocke) said : #8

So you have more than 1 monitor and you have to be sure you have understood SikuliX in a multi-monitor environment.
see comment #4

For the other problem you have another question.

The Region concept and some examples you can find in the docs.
More examples are available in the net: google : sikuli examples

Can you help with this problem?

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

To post a message you must log in.