Ruby comes with error handling and with just a few lines of code, you can get your script to recover itself when it hangs, as it sometimes will.
If you need a primer on exceptions and error handling, I recommend Alan Skorkin's post about it. As he covers a great deal of what you need to know, we will just be talking about the Watir code you will use.
And here it is:
- while !(b.frame(:id => "e1menuAppIframe").text.include? "Welcome!")
- autoit.Send("^!l")
- end
- retry
What this will do, is hit cancel until you are back at the welcome screen. So by placing this in the 'rescue' portion of your error handling and the begin statement after where you would initially be seeing the welcome screen in the first place, it will work like a dream.
I understand this won't work for all cases, but for some it will, and for those that it will, it makes the testing go that much smoother! Enjoy~
No comments:
Post a Comment