【问题标题】:Python Selenium Webdriver.Firefox() hangs at 'about:blank&utm_content=firstrun'Python Selenium Webdriver.Firefox() 在“about:blank&utm_content=firstrun”处挂起
【发布时间】:2016-09-19 15:12:18
【问题描述】:

我正在使用 Selenium 版本 2.53.6,并已在 Firefox 44、45、46 和 47 上尝试过...

每当我跑线时

driver = webdriver.Firefox()

Firefox 初始化但在“about:blank&utm_content=firstrun”处挂起,我无法在命令行上键入其他代码。

一直在研究如何解决这个问题,到目前为止,唯一对我不起作用的可用解决方案是降级 FF(但我已经尝试了许多旧版本)(我使用的是 Python 2.7,也尝试过使用 3.5 并失败了)

【问题讨论】:

标签: python selenium firefox


【解决方案1】:

我建议使用 chrome。 http://chromedriver.storage.googleapis.com/2.9/chromedriver_win32.zip 下载并解压到位于C:\\ Drive 根目录中的python27/scripts 文件夹,然后运行此脚本。

from selenium import webdriver
driver = webdriver.Chrome()
driver.get('http://www.google.com')

它应该将您连接到 google.com 希望我有所帮助。 :)

【讨论】:

  • 嗨!想试用 chromedriver,但收到此错误:“selenium.common.exceptions.WebDriverException:消息:'chromedriver' 可执行文件需要在 PATH 中。”
  • 完全按照我的方式尝试脚本,这是 python 2.7 btw
  • jovin.pizarro 我相信 chromedriver 可执行文件(Firefox 是唯一不需要单独的可执行文件的浏览器)需要在你的 python 应用程序的路径中。我真的很喜欢这个问题的选定答案stackoverflow.com/questions/29858752/…
  • @ElderSmash 你是对的。将 chromedriver.exe 放入您的 \Python\Scripts\ 文件夹将解决 @jovin.pizarro 的问题。但是,当我运行 Chrome 浏览器时,我遇到了一个新问题,而不是上述问题,它在新打开的 Chrome 浏览器的 URL 字段中给出:data:, 。所以对我来说,这又一次不起作用@thesonyman101
猜你喜欢
  • 1970-01-01
  • 2013-10-26
  • 2015-05-18
  • 2017-07-22
  • 1970-01-01
  • 2020-04-14
  • 1970-01-01
  • 2019-02-11
  • 1970-01-01
相关资源
最近更新 更多