I'm trying to perform a NavigateTop event that will redirect a current page to a new page.
I used a WaitForEvent for that WebPage object, with NavigateTop method set as Setup, while the Fired path will go back to a WaitAny. The NavigateTop method (from WebPage object) returns a boolean value. Recently, I've encountered a False return value (I'd like to ask how this happens, too). I'm expecting NavigateTop to "destroy" the page, but since it didn't (it went to the "False" path), I should be able to exit the automation via the False path. But what has happened is not only did it go to the False path and exited the automation, but it also went back to the automation and then to the Timeout of the WebPage.Destroyed WaitForEvent. So in the end, I received two error messages.
So, how do I cancel WaitForEvent such that it will not "timeout"?
You cannot cancel a WaitForEvent. The proper way to handle this is to use the timeout to reach your exit point rather than doing so from the setup link as that execution path occurs during the wait. Since you are waiting on the destroyed event though, you could potentially use a forLoop to iterate for a period of time checking the IsCreated property of the page. Using that method would allow you to effectively stop waiting if your NavigateTop method returns false.