Clicking on 2nd Text

Hi,

Is there a possibility to click on the 2nd Text ?
Suppose “Help” text appears at two places in a page and I want to click on the 2nd “Help”. How to do this without capturing an image ?

Click Text: “Help” – It clicks on the 1st Text found

Hello,

eggPlant Functional is searching the screen from the top left corner to the bottom right corner, as if it is reading English. Unless specified otherwise, it will always click on the instance closest to the top left corner of the screen. To work around this there are a few options.

One is to use the EveryImageLocation() function to find all instances of the text on the screen. You can then use code like this to click on the second instance of the word “Help”:

put everyimagelocation(Text:"Help") into HelpLocations
if the number of items in HelpLocations > 1 -- This verifies that there are multiple instances of the word
then
	click item 2 of HelpLocations
end if

For more information on the EveryImageLocation() function, see our documentation here: http://docs.testplant.com/?q=content/image-searching-commands-and-functions

You can also set a SearchRectangle using coordinates or images (as described here: http://docs.testplant.com/?q=content/working-ocr) in a way that will reliably exclude the first instance of the word “Help”, allowing you to focus on the relevant instance.

Hope that helps!

Elizabeth

Thank you ELizabeth.

What happens for an image with the same case ?
If I want the 2nd image to be found and matched, then what should be the code ?

For 1st image:-
If imagefound (30, "Image_1’)
Log Success “Image found”
else
LogError “Image not found”

You can use the same code I posted previously with an image reference instead of the reference to text. Simply substitute:

everyImageLocation("Image_1")

in place of

everyImageLocation(Text:"Help")

The code you just posted would interact with the first instance of the image found, while the code I posted works with the second instance of the text or image. You are of course welcome to modify my code as needed and incorporate your LogSuccess and LogError messages into that code.