WinForms Managing a Web Browser Reorienting?

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.

+3
source share
2 answers

Why do you need to click this button? Is he sending some form? If so, you can use WebClientand simulate a submit form without a graphical interface.

- Get Post multipart/post, WebClient . , , , , . .

+1

IE7 IProtectFocus - . , ActiveX , ​​, . csexwb. - winform, -.

+1

Source: https://habr.com/ru/post/1733801/


All Articles