tags:

views:

266

answers:

3

Anyone know how to use CertificateWarningHandler in WatiN?

I've got as far as...

IE ie = new IE("https://mysite.aspx");

CertificateWarningHandler cwh = new CertificateWarningHandler(CertificateWarningHandler.ButtonsEnum.Yes);
cwh.HandleDialog(new Window(ie.hWnd));

... which does precisely nothing.

On a more general note, how on earth do you people manage to use this tool? The documentation is nearly useless, and there doesn't seem to be any decent resource online. I must be missing something because it's taken me about half an hour to write 3 lines of code that don't even work.

+1  A: 

have you tried following already?

ie.DialogWatcher.Add(cwh);

or just

ie.DialogWatcher.Add(new CertificateWarningHandler());

Update: After comment.

Actuall this works for me. further may be following will help

Browswer browser = ie;
 if (browser.Links.Exists("overridelink"))
{
       browser.Link("overridelink").Click();
}
Saar
This doesn't work either. Isn't the dialogue watcher for handling javascript popups?
fearofawhackplanet
yep the 2nd snippet does the job, thanks
fearofawhackplanet
+2  A: 

I'm using something similar to what Saar is using and it works fine (my tests are cross-browser).

//Override security warning in browser {

                if (Browser.Link(Find.ById("overridelink")).Exists)
                {
                    Browser.Link(Find.ById("overridelink")).Click();
                    Browser.WaitForComplete();
                }
                else
                {
                    Browser.WaitForComplete();
                }   //end else
            }

I'm not a developer, and I've found that there's plenty of information out there on WatiN and others post code samples and the like that are really helpful. Google is one of my best friends when it comes to finding WatiN help. You'll get the hang of it.

Chris Forward
A: 

I had to handle the case where each user had their own security certificate, so extended WatiN to select from the certificate store automatically when presented with thus dialog.

http://www.akroyd-wallis.co.uk/src/WatiN/CertificateChoiceDialogHandler.cs

Nick