0

I wrote a browser in C# and it navigates custom pages, invokes specified buttons by using navigated "HtmlDocument". However, one of the buttons displays a confirmation box written in JS.

onclick="return confirm('Are you sure ?');"

This is not my call and how can I click on "OK" for this confirmation by using WebBrowser elements? Thanks in advance.

JoshuaJeanThree
  • 1,382
  • 2
  • 22
  • 41
  • possible duplicate of [How to simulate mouse click with the WebBrowser control](http://stackoverflow.com/questions/5150610/how-to-simulate-mouse-click-with-the-webbrowser-control) – Archlight Jul 23 '14 at 08:54
  • Sorry, but I am talking about JS confirmation that also terminates debug and other functions. Its button does not exist in HtmlDocument of the page. So, it is neither same nor similar. – JoshuaJeanThree Jul 23 '14 at 08:59
  • so you want to click on yes button after confirms appear? – faby Jul 23 '14 at 09:04
  • 1
    as a work-around I avoided the confirmation message by using this line: document.Body.InnerHtml = document.Body.InnerHtml.Replace("onclick=\"return confirm('Are you sure ?');\"", ""); – JoshuaJeanThree Jul 23 '14 at 11:21
  • @JoshuaJeanThree that is probably what you are going to have to do. That confirm message won't go away any other way, unless you have something looking at the process (on the browser) and close it. – Hanlet Escaño Jul 23 '14 at 21:03

0 Answers0