Sometimes we’ll find that our application won’t be open to TestComplete. So the application doesn’t expose any details about the it’s objects and methods, or Testcomplete may not have in-built support for the controls or windows in the application. For example we may have a browser type that is not supported by TestComplete. Equally we may have objects like toolbar buttons, icons that aren’t supported by TestComplete. To automate test on these types of applications, we can use Find Image feature.
What do we mean when we talk about automation using the Find Image feature? Using the Image of a particular control, window or object, our script will find the position of the object and then performs an action on it.
This is like finding a thief, using his photograph. The Police may aim to catch this thief but he has only the photo of that thief. He gets a clue that the thief is there in a stadium. However, when he reaches the stadium he finds around 100 people in the stadium. He looks at every persons face in the stadium. Finally he identifies the thief and arrests him. Granted it’ll take a long time to look at every face and compare it to the photo but when we’re talking about searching for objects with TestComplete this process takes a fraction of a second. With TestComplete we going to use the Find Image method to implement this process.
In General, it includes the following three steps.
To find the image on an object we have to use Regions.Find method. This method returns the identified rectangular image object.
The Syntax of this method is as follows.
Regions. Find(PictureToSearchIn , PictureToSearchFor )
This method contains a few more optional parameters. To simplify though we will take these two required parameters alone.
PictureToSearchIn – Window or Page object, on which we have to find the image
PictureToSearchFor – Image name of the object on which we want to perform action. We should have added this image in the Regions section of the Stores.
Let us consider the following scenario to be automated on the Google home page. I want to search for “Testcomplete”. But I want to automate it in chrome. To automate this scenario using Find Image, we’ll do the following.
So even though we might not have support for an application, using this approach we can automate onscreen actions.