your alert dialog is random, you may have three ways to handle it
1. check alert present or not before perform any web driver based action, such as click, but I think you may have a lot of places to add check, it will be a big effort
2. try catch all your web driver action, if there is an unexpected alert present, you will get exception "UnhandledAlertException", catch this exception and accept the alert, then perform your action again.
3. Override windows.alert function, make your web page totally not display it, you need to add this javascript into the web page, web driver can inject it for you.
Both three ways all have some weakness, the 1 & 2 needs you fix the codes in a lot of places. A fast way for it is that you can implement a new class inherit from WebDriver, WebElement and other web driver classes. add your alert checking code in each web driver actions, includes findElement or methodes. the third one does not requires much codes but it will override alert function, it also includes the intentional alert dialog.
Hope it can help you.
--david
Date: Thu, 2 Apr 2015 15:32:44 +0530