Hi all,
I am pretty new to eggplant. I am trying to locate different text images on different backgrounds in the SUT using the TIG. Eggplant is able to find all the images correctly.
But i need to do this repeatedly on different text. Is there a way to do this using a handler or a function.
I need to do something like
If ImageFound(5, “Function or handler (text to be found”) then
click FoundImageLocation()
End if
instead of
If ImageFound(5, (Text:“Some text”, TextStyle:“plain”), (Text:“Some text”, TextStyle:“bold”), (Text:“Some text”, TextStyle:“blue”), (Text:“Some text”, TextStyle:“blue_bold”), (Text:“Some text”, TextStyle:“yellow”)) then
click FoundImageLocation()
End if
Any help is greatly appreciated.
Thanks,
kris
Not sure if you really need a handler or just a repeat loop:
put ((Text:"Some text", TextStyle:"plain"), (Text:"Some text", TextStyle:"bold"), (Text:"Some text", TextStyle:"blue"), (Text:"Some text", TextStyle:"blue_bold"), (Text:"Some text", TextStyle:"yellow")) into textItems
repeat with each item of textItems
try
click it
end try
end repeat
The reason I’m not sure you need a handler is because it ends up having almost no code in it:
repeat with each item of ((Text:"Some text", TextStyle:"plain"), (Text:"Some text", TextStyle:"bold"), (Text:"Some text", TextStyle:"blue"), (Text:"Some text", TextStyle:"blue_bold"), (Text:"Some text", TextStyle:"yellow"))
clickText it
end repeat
on clickText myTextList
try
click myTextList
end try
end repeat
It doesn’t really buy you anything. The try block has about the same effect as your if imagefound()/click foundimageLocation() code – it tries to find the image and click it, and if it can’t the exception is caught by the try block.