You may need to find an image or a text on the screen during executing a scenario but the robot is not finding it because the location of the image/text changes for various reasons.
This post will teach you how to easily set a search area for a text or an image that has a dynamic position on the screen.
I will use “Read Text Into a Variable” action in my example but the solution can be used for any action that has a search area property.
Challenge:
Imagine you need to capture a text such as a price, a ticket number or an id from an XML file as shown in image below:
If you set a search area for the price tag, it works perfectly for a single iteration. However, for other iterations (different menu entries, or other data combinations,…) the price element can move up or down on the screen. So what is the best way to define a search area for the price element that can appear in different locations without hardcoding any coordinates? Let’s find out!
Solution:
1. First, add a “Find Image” action for image
2. Next, go to the image properties and define an (x,y) for “Stored Image Coordinates”.
3. Change the “Anchor Position X” to “right” and change the “Anchor Position Y” to “top”.
4. Then, add a “Find Image” action for image
5. Go to the image properties and define an (x,y) for “Stored Image Coordinates”.
6. Change the “Anchor Position X” to “left” and change the “Anchor Position Y” to “bottom”.
7. Finally, add “Read Text Into a Variable” action and set the Text Area based on the images stored coordinates.
Here is the sample scenario:
Attached please find the sample scenario if you want to give it a try.