Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium - Unresponsive Script Error (Firefox)

This question has been asked before, but the answer given does not seem to work for me. The problem is, when opening a page using Selenium, I get numerous "Unresponsive Script" pop ups, referencing varying scripts.

When I open the page using Firefox without Selenium, I get no errors. Also, oddly, when I open the page using selenium manually it works. So I can't even pinpoint the problem.

I can share the code, but doing so isn't necessary. Essentially what happens is this:

  1. Program collects tuple of urls from MySQLdb
  2. Creates list of URLS
  3. Attempts to open URLS either using urllib2, or selenium, based on certain factors.
  4. When opening using selenium, creates new instance each time, so:
driver = webdriver.Firefox()
driver.get(url)
do other things (either open links or get page source)
driver.close()

As far as I can tell, the error is occurring on the second step (get url).

I have set the script wait condition in about:config to very high numbers, and 0, and I still get the error.

Is there a solution to this problem?

Note, I am not opening my own pages for testing purposes. Rather, i am opening a third party site, to obtain certain data. Note also, that sometimes volume can get pretty high (a lot of pages being opening by different programs at the same time) - maybe that's the problem??

My problem right now is mostly that I can't even replicate the problem on another computer, I am just completely lost. I hoping someone else out there has had a similar problem and found a solution. I have a feeling this has something to do with the settings in Firefox (not about:config).

like image 810
Neil Aggarwal Avatar asked Sep 25 '13 07:09

Neil Aggarwal


2 Answers

After trying many settings, I think I have found one that works, and, alas, it was mentioned here, I just didn't really understand how to use it (b/c I had never dealt with firefox profile setting in selenium): Selenium & Firefox: How can i turn off "Unresponsive script" warnings?

The solution is as follows:

from selenium import webdriver
fp = webdriver.FirefoxProfile()
fp.set_preference("dom.max_chrome_script_run_time", 0)
fp.set_preference("dom.max_script_run_time", 0)
driver = webdriver.Firefox(firefox_profile=fp)
like image 53
Neil Aggarwal Avatar answered Nov 19 '22 12:11

Neil Aggarwal


public class Send10000CharactersToChat {
private static WebDriver firefoxDriver;
@Before
public void initialize() {
    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("dom.max_chrome_script_run_time", 0);
    profile.setPreference("dom.max_script_run_time", 0);
    firefoxDriver = new FirefoxDriver(profile);
    }
}
like image 1
Andrii Dudchenko Avatar answered Nov 19 '22 10:11

Andrii Dudchenko