A Firefox Extension that automatically closes alerts. Its intention is to aid in running Selenium scripts.
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 1 commit behind zenchild:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
chrome/content
defaults/preferences
LICENSE
README
chrome.manifest
install.rdf

README

My blog post on this issue:  http://distributed-frostbite.blogspot.com/2010/02/closing-javascript-alerts-in-selenium.html

This is a simple Firefox extension that I use to close unexpected alert boxes while running Selenium tests.  Prior to this the alerts where out of context and Selenium could not control them.  You can see the Selenium-RC FAQ for more information:
http://wiki.openqa.org/display/SRC/Selenium+RC+FAQ

While watching Jason Huggins' presentation on Hacking Selenium ( http://www.infoq.com/presentations/huggins-hacking-selenium ), he demonstrated a way to close the alerts at the browser layer (XUL).  This method was sent to him by Aaron Boodman of Greasemonkey fame.  I (Dan Wanek) have taken the base of Aaron's code and turned it into a simple Firefox extension.  It has worked for me in all of the instances that I have needed it, but if you are having issues you may need to tweak the alertCloser.alertClose method to make it more general use.

There is a preference you can set: extensions.alert_closer.millisbeforeclose which defaults to 1000.

Enjoy!


To create the XPI for installation into Firefox simply change to the "FirefoxAlertCloser" directory and zip up the contents.  For example:

    git clone git://github.com/zenchild/FirefoxAlertCloser.git
    cd FirefoxAlertCloser
    zip -r ../alert_closer.xpi . -x ".git/*"

Now just go into Firefox and open the xpi file you created.  I would recommend doing this in a special Firefox profile for Selenium testing.