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

时间:2015-05-30 17:50:44

标签: python html firefox selenium selenium-webdriver

我试图在Selenium中使用Python抓取并打印网页的HTML,但每次运行时都会收到错误消息

Firefox quit unexpectedly.

我是Selenium的新手,所以任何帮助都将不胜感激。我希望能够做到最简单的解决方案。谢谢!

我的代码:

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

3 个答案:

答案 0 :(得分:7)

自从几周前在Windows上升级到Firefox 38.x以来,我的经验是Selenium 2.45.x存在问题。调用浏览器时会产生“Firefox已停止工作”错误,我必须手动关闭,此时测试运行。 Others have reported similar issues

对我有用的解决方案(除了每次手动关闭错误,几天后就老了)是在我运行测试的机器上卸载最新版本的Firefox和downgrade to version 37.0.2。出于安全考虑,这并不理想,但如果你小心的话,那就没关系。

答案 1 :(得分:2)

将Selenium从2.45升级到2.47对我有用。

Selenium 2.46修复了对Firefox 38的支持(看起来也像39)。 请参阅release notes

答案 2 :(得分:1)

您使用的是什么版本的Firefox? firefox 36开始为我打破selenium版本2.43.0。您可以升级到2.45并检查。 https://code.google.com/p/selenium/issues/detail?id=8399他们最后提到2.45中有ff 36的修正案。对于ff 37及以后我不确定。我将我的ff降级为使用我的硒版本。

相关问题