This is not only annoying but also hearts the efforts for producing unattended scripts.
Google again come to rescue and i got this from. So the solution goes like:
Go the hidden configuration page in Firefox by typing about:config in the address bar . (make sure that you are doing this for the profile you are using for selenium)
In the 'Filter' box, type script_run_time. This will narrow the options to dom.max_script_run_time and dom.max_chrome_script_run_time.
Right-click it and choose Modify. A box pops up. Change the number to something bigger like 40. This is the maximum time a script can run before Firefox considers it 'unresponsive'.
If you can’t find the string in the about:config page, create it by right-clicking anywhere and then choose New—> Integer and enter there name.