简体   繁体   English

“Firefox意外退出。”在Python中运行基本的Selenium脚本时

[英]“Firefox quit unexpectedly.” when running basic Selenium script in Python

I'm trying to scrape and print the HTML of a page using Selenium in Python , but every time I run it I get the error message 我正在尝试使用Python Selenium来抓取并打印页面的HTML,但每次运行它时都会收到错误消息

Firefox quit unexpectedly.

I'm new to Selenium, so any help would be greatly appreciated. 我是Selenium的新手,所以任何帮助都将不胜感激。 I'm hoping for the simplest fix possible. 我希望能够做到最简单的修复。 Thank you! 谢谢!

My code: 我的代码:

import selenium
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://seleniumhq.org/')
print browser.page_source

My experience since the upgrade to Firefox 38.x on Windows a couple of weeks back has been that it has a problem with Selenium 2.45.x. 我几周前在Windows上升级到Firefox 38.x以来的经验是它与Selenium 2.45.x有问题。 When invoking the browser it produces a "Firefox has stopped working" error which I have to close manually, at which point the test runs. 调用浏览器时会产生“Firefox已停止工作”错误,我必须手动关闭,此时测试运行。 Others have reported similar issues . 其他人报告了类似的问题

The solution that worked for me (apart from manually closing the error each time, which got old after a few days) was to uninstall the latest version of Firefox and downgrade to version 37.0.2 on the machine where I run the tests. 对我有用的解决方案(除了每次手动关闭错误,几天后老了)是卸载最新版本的Firefox并在我运行测试的机器上降级到版本37.0.2 Not ideal for security reasons, but OK if you're careful. 出于安全考虑,这并不理想,但如果你小心的话可以。

Upgrading Selenium from 2.45 to 2.47 worked for me. 将Selenium从2.45升级到2.47对我有用。

Selenium 2.46 fixes support for Firefox 38 (and looks like 39 as well). Selenium 2.46修复了对Firefox 38的支持(看起来也像39)。 See the release notes 请参阅发行说明

What version of firefox are you using? 您使用的是什么版本的Firefox? firefox 36 started breaking for me with selenium version 2.43.0 . firefox 36开始为我打破selenium版本2.43.0。 You can upgrade to 2.45 and check. 您可以升级到2.45并检查。 https://code.google.com/p/selenium/issues/detail?id=8399 They mention at the end that there are fixes for ff 36 in 2.45. https://code.google.com/p/selenium/issues/detail?id=8399他们最后提到2.45中有ff 36的修复程序。 For ff 37 and beyond I'm not sure. 对于ff 37及以后我不确定。 I downgraded my ff to work with the version of selenium I had. 我将我的ff降级为使用我的硒版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM