Wednesday, September 5, 2012

Dealing With Browser Certificates


IE:

The watir documentation has a workaround for this:

my_browser.link(:id, "overridelink").click

Another solution for this is to use autoit to tab into the 'continue to website', saves having to add to website all the time

    autoit=WIN32OLE.new('AutoItX3.Control')
    i=1
    while i < 11 
        autoit.Send("{Tab}")
        i+=1
    end

    autoit.Send("{Enter}")

Firefox:

The Firefox driver properly handles untrusted certificates by default.

If you have a trusted certificate, but there is some other certificate error such as a hostname mismatch (eg. using a production certificate in test), you should do the following:

profile = Selenium::WebDriver::Firefox::Profile.new
profile.assume_untrusted_certificate_issuer = false
b = Watir::Browser.new :firefox, :profile => profile
The reason this is needed is explained here.

Chrome:

It is easy to ignore invalid Browser certificates in Google Chrome by passing a command line switch:

Watir::Browser.new :chrome, :switches => ['--ignore-certificate-errors']

1 comment:

  1. It appears that Watir does this by default now. So, what if you do *not* want to ignore certificate errors?

    ReplyDelete