Selenium-无响应脚本错误(Firefox) [英] Selenium - Unresponsive Script Error (Firefox)
问题描述
此问题曾被问过,但给出的答案似乎对我不起作用.问题是,当使用Selenium打开页面时,我看到许多无响应脚本"弹出窗口,它们引用了各种脚本.
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.
当我使用不带Selenium的Firefox打开页面时,没有任何错误.另外,奇怪的是,当我手动使用硒打开页面时,它可以工作.所以我什至无法找出问题所在.
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:
- 程序从MySQLdb收集URL的元组
- 创建URL列表
- 根据某些因素,尝试使用urllib2或Selenium打开URL.
- 使用硒打开时,每次都创建一个新实例,所以:
- Program collects tuple of urls from MySQLdb
- Creates list of URLS
- Attempts to open URLS either using urllib2, or selenium, based on certain factors.
- 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()
据我所知,错误发生在第二步(获取URL).
As far as I can tell, the error is occurring on the second step (get url).
我已将about:config中的脚本等待条件设置为非常高的数字,即0,仍然出现错误.
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??
我现在的问题主要是我什至无法在另一台计算机上复制该问题,我完全迷失了.我希望外面的其他人也遇到类似的问题,并找到了解决方案.我觉得这与Firefox中的设置有关(与about:config无关).
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).
推荐答案
尝试了许多设置之后,我认为我找到了一个可行的设置,可惜在这里提到了,我只是不太了解如何使用它(我从未处理过硒中的firefox配置文件设置):
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?
解决方案如下:
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)
这篇关于Selenium-无响应脚本错误(Firefox)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!