"Wait until True" activity

I would appreciate an activity that delays the robot until a given condition becomes True (or it times out). As an example, say we’re waiting for a report to download into a directory, and we wish to read this report into memory once it becomes available. In this case we could do something along the lines of:

int fileCountBefore = Directory.GetFiles( myDir ).Count();
downloadReport();
WaitUntilTrue( Directory.GetFiles(myDir).Count>fileCountBefore );
FileInfo mostRecentReport = DirectoryInfo.GetMostRecent();
RetryScope( ) { FileStream reportStream = mostRecentReport.Open(FileMode.Open, FileAccess.Read) }
readReport();

This could be achieved combining a while-loop and a Stopwatch (for timeout), but it’s messy. The same argument could be made for the “Wait attribute”, “Wait Element/Image Vanish” and “On Element Appear”, but I’m sure a lot of people find these activities handy - I know I do.

How about File Change Trigger (Created) instead of WaitUntilTrue( Directory.GetFiles(myDir).Count>fileCountBefore );

1 Like

That’s a clever solution to this problem in particular - however, your solution still requires the use of a “Monitor events” activity, and a Stopwatch if you desire a certain timeout, which all could be avoided with a WaitUntilTrue activity. It also only works if you are waiting for a single file to download.

Furthermore, I believe there are plenty other use cases for a WaitUntilTrue activity than the one in my example. For instance - of the top of my head - one could use it to monitor a mail inbox for incoming mail, wait for a stock price to reach a certain level, wait for a read/write-block to be lifted, etc.

1 Like