OCR - Get text using text
#
DescriptionThis action allows you to extract text based on its position in relation to the text you specified. You also have to provide the direction of the text corresponding to the text that you provided. The direction can be one of the following four, left, right, top, bottom. This action tries to find the text that you provided using the OCR method. Thatâs why there are some optional parameters like method and threshold to find your given text first. Then based on the direction you provided you are able to extract the text you desire. You can also provide an integer as the text gap option to be more specific about the text you want to extract. A variable name also has to be provided to store the extracted text. The following 2 scenarios should give you an idea of how you can implement the action
Scenario 1:
Suppose you want to extract the Remote Port number shown in the above image, that is 4723. In that case, you have to mention the text âRemote Portâ in the text row (the first row) of the action. As 4723 is on the right side of the right side of Remote Port, the value for the direction row will be right. Finally, you should also provide a variable name in the last row that will hold the extracted text. The text â4723â will be successfully stored in that variable.
Scenario 2:
Suppose you want to extract the word âSauceLabsâ using the text âBrowserStackâ. Then you have to provide the text âBrowserStackâ in the text row (the first row) of the action. As âSauceLabsâ is above the BrowserStack, here the direction will be top. Now the text âSauceLabsâ will be stored in the variable you provided in the final row.
Optional Parameters:
text gap: Now, letâs see how we can use the âtext gapâ option. With the help of the given text, we can extract text adjacent to the given text. Now this adjacency can be defined using the âtext gapâ option. Let us consider the following 2 scenarios
Scenario 1:
Suppose you want to extract the word âCurrent Advanceâ using the text âInterest Deductionsâ.
Now as you can see the word âCurrent Advanceâ is located right to the âInterest Deductionsâ but it's not aligned horizontally with the âCurrent Advanceâ. So if we declare the text and set the direction to right we will not be able to extract anything as the words are out of alignment as shown in the following image.
But if we set the text gap to 300 then the word âCurrent Advanceâ gets aligned with the word âInterest Deductionsâ as we have added 300 pixels. Now the range gets broader and any word that falls within that range can be considered as an adjacent word. This way you can extract words that may not be extracted generally.
Scenario 2:
Suppose you want to extract the word above âSauceLabsâ.
In this case, you are hoping to extract the word âSelect Cloud Provideâ as it is right above âSauceLabsâ. But if you run the action without specifying the text gap option you will see you extracted the word âRemote Portâ.
As you can see in the above image the range for which a word can be considered as an adjacent word of the âSauceLabsâ does not involve the word âSelect Cloud Provideâ but involves the word âRemote Portâ. So the word âRemote Portâ gets extracted instead of âSelect Cloud Provideâ. Now if you widen the range using the text gap option you will be able to extract the word âSelect Cloud Provideâ as you desire.
method: For the given text, if the exact text is not found then the method option lets you select the closest text based on some given parameters like "match", "partial match", "loose match". If you use the "match" option then the similarity between the texts has to be very strong to get a good score but if you select "loose match" then even weaker similarity will produce a good score. Suppose, you have specified a text, "E-Transfer Total" and the OCR was able to pick up "Transfer Tol". Now, if you use the "match" option then the score between these two texts will be 86 but if you selected "loose match" as the method then you will get a score of 92. The "partial match" should give a score in between those two scores. So according to your need, you can specify different parameters.
threshold: Previously we talked about different methods of matching and how they produce different scores. Now we can specify a threshold that will allow us to have more control over when we want to click something based on what score. Suppose we want to be strict in case of clicking. In that case, we can set the threshold to 90 so that only when the score of text matching is above or equal to 90, we can execute a click. If you want an exact match then set the threshold to 100.