Hello,
You can do this by creating a separate script. Call this new script “IfThenElse”. In the new script, you will have the below code:
Params ImageTime, ImageName, Action
if imagefound (ImageTime, ImageName)
then
log "Expected image was found, so clicking: " & ImageName
do action && ImageName
else
LogError "Expected Image Not Found: " & ImageName
end if
Then, in your main script, you will call IfThenElse.script with code like this:
//Do Something
IfThenElse 15.0, "Image1", click
//Do Something
IfThenElse 30.0, "Image2", doubleClick
Make sure that the new script is named “IfThenElse”, or the code above will not call it properly!
The advantage of creating a separate script is that then you can use that bit of code from any other script in the suite (and in other suites, as long as the suite that holds the IfThenElse script is added as a helper or into the InitialSuites).
If (for whatever reason) you would rather, his can also be done within a single script. To do this, you would just call the code in the same way in the main script, but instead of having a separate script, you would have a handler. Your code would then look like this:
//Do Something
IfThenElse 15.0, "Image1", click
//Do Something
IfThenElse 30.0, "Image2", doubleClick
//This is the handler being called (at bottom of script):
to IFThenElse ImageTime, ImageName, Action
if imagefound (ImageTime, ImageName)
then
log "Expected image was found, so clicking: " & ImageName
do action && ImageName
else
LogError "Expected Image Not Found: " & ImageName
end if
end IfThenElse
I hope that helps!
-Elizabeth