Selenium - Unresponsive Script Error (Firefox)

2024/4/15 2:00:26

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).

Answer

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)
https://en.xdnf.cn/q/73266.html

Related Q&A

Fail to validate URL in Facebook webhook subscription with python flask on the back end and ssl

Im trying to start using new messenger platform from FB. So i have server with name (i.e.) www.mysite.com I got a valid SSL certificate for that domain and apache is setup correctly - all good.I have …

What is a proper way to test SQLAlchemy code that throw IntegrityError?

I have read this Q&A, and already try to catch exception on my code that raise an IntegrityError exception, this way :self.assertRaises(IntegrityError, db.session.commit())But somehow my unit test …

What are the different options for social authentication on Appengine - how do they compare?

[This question is intended as a means to both capture my findings and sanity check them - Ill put up my answer toute suite and see what other answers and comments appear.]I spent a little time trying t…

Is there any way to get source code inside context manager as string?

Source code of function can be received with inspect.getsourcelines(func) function. Is there any way to do same for context manager?with test():print(123)# How to get "print(123)" as line he…

Create temporary file in Python that will be deleted automatically after sometime

Is it possible to create temporary files in python that will be deleted after some time? I checked tempfile library which generates temporary files and directories.tempfile.TemporaryFile : This functi…

Python GTK+ Canvas

Im currently learning GTK+ via PyGobject and need something like a canvas. I already searched the docs and found two widgets that seem likely to do the job: GtkDrawingArea and GtkLayout. I need a few b…

Python, can someone guess the type of a file only by its base64 encoding?

Lets say I have the following:image_data = """iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="""This i…

Extract only body text from arXiv articles formatted as .tex

My dataset is composed of arXiv astrophysics articles as .tex files, and I need to extract only text from the article body, not from any other part of the article (e.g. tables, figures, abstract, title…

why is python reusing a class instance inside in function

Im running a for loop inside a function which is creating instances of a class to test them. instead of making new classes it appears to be reusing the same two over and over.Is there something Im miss…

How to set locale in Altair?

Im successfully creating and rendering a chart in Altair with a currency prefix ($), but I need this to be set to GBP (£). I know that theres a Vega-lite formatLocale which can be set, but I cant …