Hi, I made a browser automation for a specific site. I used Timer to handle the task one by one. But sometimes it stuck. What's the best Practice to Handle this kind of browser automation with Multi Tasking Properly? :)
Printable View
Hi, I made a browser automation for a specific site. I used Timer to handle the task one by one. But sometimes it stuck. What's the best Practice to Handle this kind of browser automation with Multi Tasking Properly? :)
I'm afraid that your question is rather too vague to give much meaningful advice but there's every chance that the way you're using a Timer or even that you're using a Timer at all is the issue. We'd have to know far more about the specifics though.
Ok, Let me Make it clear. I have to Fillup form and Click Register button. After clicking Register button I simply disable the Timer untile getting the registration response because IF I Enable Timer It clicks Register Button Frequently. In this circumastances, due to slow Internet connection I have to wait 20/30 seconds Or even more than 1/2 minutes to get any response. But unluckly If It does not Get response It would Remain stuck. So, My Question is: IS timer best option for this type of Browser Automation?
Are you talking about a WebBrowser control in your own form? That's rather pertinent information.
Yes, I'm using GeckoFX 33.0.
That would fall under the category of "specifics". I've never used that control so I can't really help much further with it specifically but I will say that the standard WebBrowser control has a DocumentCompleted event that notifies you when a page has finished loading so you should probably look for something similar in the control you are using.
That said, if there's a chance that you might not get such an event because a page fails to load then you probably should use a Timer, but not in the way that you currently are. Each time you perform an action that navigates to another page, you could start a Timer as a failsafe. If you get a DocumentCompleted event or the like before the Timer Ticks then you Stop the Timer and perform the next action. If the Timer Ticks first then you would consider the action to have timed out and you can then proceed accordingly. It's up to you to set the Interval of the Timer to a suitable value for the timeout on each action.
Thank you. Actually, I'm also using DocumentCompleted event in Gecko. It's much More Advance than IE. But sometimes it stucks. It's not Just registration there are many Tasks after Registration. That's why I'm looking for proper solution.
The DocumentCompleted event is the way to determine that a document has loaded. If there's no event that indicates that a document has failed to load then you would use a Timer to create your own timeout mechanism. That's basically it.