I am assuming you need help on step2?
I have a configurable value for taking the number of screenshots, let's call this 'x'.
Then all I do is simply loop and take x number of screenshots after step1. Then I save all these screenshots into a directory.
The reason why I take all the screenshots first and then save the screenshots after loop is done is to increase my chance of catching the toast message in my screenshots.
Does this help?