How to continue from FindFailed exception in sikuli, instead of re executing the entire script

Viewed 1272

I am a game tester have to click on a particular "Spin" button image several times.

In this process of identifying the spin button image with sikuli I get the Exception in thread "main" FindFailed. I basically use Eclipse as IDE and Selenium WebDriver with Java.

I would like to continue the test from where it failed earlier instead of re-running the entire script, can you please guide me with the code to run the script from where I got error earlier?

1 Answers

Just add some exception handling logic in your flow. For example:

int retries = 3;

for (int i = 0; i < retries; i++) {
  try {
    //do whatever you need that can throw an exception
    break; //will break the loop once the above operation succeeded
  } catch (FindFailed e) {
    Thread.sleep(1000); //wait for one sec (if needed)
  }
Related