[eggPlant Functional] WaitForAll Image's in a Folder

As we were adding Image Collections to Eggplant 4.0 we looked at whether it made sense to have WaitForAll behave differently for collections (and do an All rather than an Any when a folder was referenced).

Because the purpose of Image Collections is to allow for the easy addition of multiple image states we chose to keep the “Any” for Image Collections (even within the WaitForAll command).

However sometimes you might want to have a folder that you use as an ALL collection. That can be accomplished with this script, WaitForAllCollection, you can use it just like WaitForAll with an initial timing parameter and then image or image folder

It illustrates a few things from 4.0:
[list]It uses ImageInfo(FolderName) to get all ImageInfo for a folder using collections
It uses the new 4.0 “PROPERTY of each item of” syntax.
It also is a good illustration of making your own “Eggplant Command” using the primitives we provide.
[/list:u]


(* WaitForAllFolder -- Waits for all images in the folder *)
params timeToWait, FolderName

insert timeToWait before images
insert "ImagePath" of each item of imageInfo(FolderName) after images

waitForAll images as parameters

Hey,

I’m new to Eggplant, and the current intended use of “waitforall” (and why it’s deprecated) is a discussion I missed long ago.

I’m looking at the code snippet on this post, and the code included in the download file, and they’re not exactly the same. What am I missing?

In short, I’d really like to use a folder name and have the system look for ALL the images in that folder. I don’t understand the SenseTalk syntax very well yet, and the use of “…as parameters” is not clear to me.

So, on a different note, why can’t I use waitfor in a loop and override waitforall as follows: (sorry if my syntax is off, I’m new)

(* WaitForAllFolder.script
*)

WaitForAllFolder MyWaitTime, MyImageFolderName

repeat with MyImage = each image in MyImageFolderName
try
waitfor MyWaitTime, MyImage
catch MyException
put "Image not found: " && ImageName(MyImage)
log MyException
return
end try
end repeat

Because, that’s all a “waitforall” is right, just multiple “waitfor” commands hiding under one umbrella?

(Oh, and I’m not sure the “…= each image in …” is correct syntax, is it?)

Thanks for the help!

-Dennis

Happy to have you working with Eggplant.

So first, just to clarify – WaitForAll is not deprecated it just operates a little differently on folders and lists than some people might expect. Namely it follows image collection behavior (OR behavior) by default rather than grouping those images and waiting for ALL of them (AND behavior).

We had tweaked up the script to be a little more robust and handle multiple parameters, but otherwise the code functions the same way.

An important distinction of WaitForAll (rather than sequential WaitFor’s) is that the images MUST appear simultaneously for Eggplant to validate and pass the command. It also means the time component is shared so

WaitForAllFolder 10, FolderOfImages

should stop searching after 10 seconds and give up. Not 10 seconds times the number of images in the folder.

I hope that helps clarify the distinction but as always if you have questions please don’t hesitate to ask.