We all created handlers at some point in time in our scripts ( What is a Handler?).
What is your favorite handler? The most reliable and most used. What is your story behind the use of it?
Share Today With Our Eggplant Community! Together We Learn!
We all created handlers at some point in time in our scripts ( What is a Handler?).
What is your favorite handler? The most reliable and most used. What is your story behind the use of it?
Share Today With Our Eggplant Community! Together We Learn!
I hope that you find this helpful. It takes two parameters: the coordinates for a row header (as a rectangle) and a column header (as a rectangle).
function CalculateSearchAreaForIntersectionOfRowAndColumn myRowRectangle, myColumnRectangle
set tmpSearchArea_L = left(myColumnRectangle) - .5 * width(myColumnRectangle)
set tmpSearchArea_T = top(myRowRectangle) - .5 * height(myRowRectangle)
set tmpSearchArea_R = right(myColumnRectangle) + .5 * width(myColumnRectangle)
set tmpSearchArea_B = bottom(myRowRectangle) + .5 * height(myRowRectangle)
set tmpSearchArea to (tmpSearchArea_L,tmpSearchArea_T,tmpSearchArea_R,tmpSearchArea_B)
Log "The search area is"&&tmpSearchArea
Return tmpSearchArea
end CalculateSearchAreaForIntersectionOfRowAndColumn
The handler documents the step and stops the script if the step fails.
To handle ClickImage with imageName, params:{}
CaptureScreen(increment:yes)
set params.imageName to imageName
If params.waitTime is empty then
set params.waitTime to 20
End if
If ImageFound(params) then
Click FoundImageLocation()
LogSuccess("Button " & imageName & " was pressed!")
Else
LogError("Button " & imageName & " was not pressed!")
Exit all
End if
End ClickImage
Another handler returning a search rectangle. It uses different images to search for the required area.
To handle FindSearchArea with imageTL, imageBR,\
imageTop:"", imageBottom:"",\
imageLeft:"", imageRight:"", offset:[0,0,0,0],searchRectangle:[]
Try
put ImageRectangle(imageName:imageTL, waitFor:20, searchRectangle:searchRectangle) into rectImageTopLeft
put ImageRectangle(imageName:imageBR, waitFor:20, searchRectangle:searchRectangle) into rectImageBottomRight
put topLeft of rectImageTopLeft into topLeftCoord
put bottomRight of rectImageBottomRight into bottomRightCoord
put topLeftCoord &&& bottomRightCoord into searchRect
If imageTop is not "" then
put ImageRectangle(imageName:imageTop, waitFor:20, searchRectangle:searchRectangle) into rectImageTop
put bottom of rectImageTop into item 2 of searchRect
End if
If imageBottom is not "" then
put ImageRectangle(imageName:imageBottom, waitFor:20, searchRectangle:searchRectangle) into rectImageBottom
put top of rectImageBottom into item 4 of searchRect
End if
If imageLeft is not "" then
put ImageRectangle(imageName:imageLeft, waitFor:20, searchRectangle:searchRectangle) into rectImageLeft
put right of rectImageLeft into item 1 of searchRect
End if
If imageRight is not "" then
put ImageRectangle(imageName:imageRight, waitFor:20, searchRectangle:searchRectangle) into rectImageRight
put left of rectImageRight into item 3 of searchRect
End if
put searchRect + offset into returnRect
put True into rectFound
Catch theException
put the RemoteScreenRectangle into returnRect
put False into rectFound
Log "Problem finding the search rectangle. Exception: " & theException
End try
Return (returnRect, rectFound)
End FindSearchArea