MSHTML - Auto Click for javascript confirm dialog

Posted by Soliton on Stack Overflow See other posts from Stack Overflow or by Soliton
Published on 2009-02-25T22:18:53Z Indexed on 2010/06/15 16:42 UTC
Read the original article Hit count: 746

Filed under:
|
|

I try to automatically parse/submit web page using MSHTML (in C#.Net 3.1 WPF WebBrowser control). I can fill the forms, click buttons, naviagate pages without problems. But do not know how to automatically click "ok" button on javascript confirmation dialog which appear when I click "Submit" button.

C# code: mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2)webBrowser.Document; mshtml.IHTMLFormElement form = doc.forms.item("inputForm", 0) as mshtml.IHTMLFormElement; mshtml.IHTMLElement btnSubmit = form.item("btnFormSubmit", null) as mshtml.IHTMLElement; btnSubmit.click();

The confirmation dialog ("Are you sure?" appears. I want somehow to send "Enter" keystroke to MSHTML document to automatically confirm the submission.

© Stack Overflow or respective owner

Related posts about dialog

Related posts about mshtml