Filling out some web form programmatically using the WebBrowser WPF control

I need to pre-fill out some form on some web page in my WPF application (the web page is on an external website), I use the WPF WebBrowser control.

Is there any way to do this.

I have some suggestion: emulating keyboard shortcuts and using the tab key to navigate fields (how to do this).

EDIT

The desired shape is so complex and the element names are dynamic, but they are always in the same order.

+4
source share
1 answer

if you want to submit the form you are checking

// get the document mshtml.IHTMLDocument2 doc = ((mshtml.HTMLDocumentClass)webBrowser1.Document); // set a variable ((mshtml.IHTMLElement)doc.all.item("q")).setAttribute("value", "my input..."); // click a button ((mshtml.HTMLInputElement)doc.all.item("btnI")).click(); 

The mshtml namespace is located in Microsoft.mshtml Assembly.

Just add the link Microsoft.mshtml.

hope this helps

+5
source

All Articles