Thursday, November 13, 2008

Security Alerts Interceptor for Selenium-IDE

There are 2 kinds of HTTPs Certification Security Alerts in Firefox.
1) Domain name mismatch
2) Certificate expired
Read http://kb.mozillazine.org/Security_Error:_Domain_Name_Mismatch_or_Server_Certificate_Expired
Unfortunately, Firefox 2 didn't provide a preferences entry to disable or hidden alerts.
These annoyed alerts slow down selenium speed and block selenium automation if we don't click out alerts.

There is a Firefox extension Remember Mismatch Domains(RMD.xpi) to add a "Don't warn me again about this certificate for this domain" checkbox to the Domain Mismatch and Expired Certificate warning windows. When selected the domain name and security certificate domain pair (or certificate and expiration date pair) is stored in a Firefox preference and the security error dialogue will be bypassed on subsequent visits.

The author provided a XPCOM to destroy Security Alerts Window before it displays in Firefox. We can integrate this XPCOM with Selenium-IDE and provide Security Alerts Interceptor feature.

Here are steps and code:
1) copy /platform folder from RMD.xpi to selenium-ide.xpi
2) copy rmdBadCertHandler.js and rmdIBadCertHandler.xpt to /components folder
3) edit rmdBadCertHandler.js
_isRemembered: function (handler_type, target_url, cert) {
   return true;
   //intercept and kill all security alerts
   //or add a preference entry here and return true or false
   ...
}
NOTE: it is used for Firefox 2 only. Firefox 3 has a new security exception handler.

1 comment:

  1. Jerry,
    I'm very new to Selenium - just a couple of days.
    I'm working on a test for the first page of my employer' website - it's a login page.
    I unable to get Selenium to automatically get rid in any way of the Firefox pop up "Do you want Firefox to remember this password?"
    Do I understand your post right: there's no way right now to automate it?
    Thank you

    ReplyDelete