JavaScript Alerts and Selenium/Webdriver.

JavaScript Alerts and Selenium/Webdriver.

One of the most popular question among selenium/Webdriver users. I used that couple of places to handle.

Selenium RC: if you are expecting javaScript alert and  you want to handle using OK then use following commands and then you can use your code.


Note: In Firefox 4.0 and higher version, you will see alerts like following and its impossible to handle this via selenium.

There is a workaround to handle this.

Type ‘about:config’ in Address bar of firefox browser and accept the warning.

Type “tab_”. You will see prompts.tab_model.enabled option with Value: true.

Double click on the row which will make it false.

Now alert will look like:



There is command to handle alert are:


You can handle as per your need.


Leave a Reply