I am trying to automate a web process where I need to click a button several times. When my code “clicks” on this button (the HtmlElement element obtained from the WebBrowser control that I have on my form), it returns focus back to my application, in particular, the WebBrowser control. I want to better automate this process so that the user can do other things during the process, but this cannot happen if the window is self-financing as it reaches focus.
Button related code:
HtmlElement button = Recruiter.Document.GetElementById("recruit_link");
button.InvokeMember("click");
I also tried button.RaiseEvent ("onclick"), and I get accurate results with focus problems and everything.
I also tried to hide the form, but when the InvokeMember / RaiseEvent method is called, everything I worked loses focus, but since the form is not visible, the focus seems to be useless.
The only thing that is not related to the standard for a web browser is that the URI is set to my page and the ScriptErrorsSuppressed is set to True.
source
share