【问题标题】:Selenium - socket.error: [Errno 111] Connection refusedSelenium - socket.error:[Errno 111] 连接被拒绝
【发布时间】:2018-11-07 05:05:24
【问题描述】:

我正在尝试为我的 Web 应用程序创建 Selenium 测试。到目前为止,我有:

from selenium import webdriver
import httplib

driver = webdriver.Chrome('v1/chromedriver-Linux64')
#in tutorial, it was just webdriver.Chrome() but that didn't work

url = "http://127.0.0.1:8000/loty/accounts/login/"
try: 
    driver.get(url)
except httplib.BadStatusLine as bsl:
    pass
#in tutorial, it was just driver.get(url) but that didn't work

driver.find_element_by_css_selector("#menu")

不幸的是,我收到了一个以socket.error: [Errno 111] Connection refused 结尾的long traceback。我怎样才能让它工作?

【问题讨论】:

  • 当你运行这段代码时,你知道你的 selenium 服务器是否在运行吗?
  • 我认为我没有任何 selenium 服务器。我只是从 Pycharm 运行脚本(右键单击 -> 运行“测试”),或者从 virtualenv 运行它(源 bin/activate,python test.py)。两种方式都会产生相同的错误。
  • 你下载了chrome的geckodriver吗?
  • 我已经下载了 chromedriver,尝试“pip install geckodriver”给出“找不到满足 geckodriver 要求的版本(来自版本:)没有为 geckodriver 找到匹配的发行版”
  • 嗯,好的,你有什么版本的chrome,你安装了什么geckodriver版本?

标签: python django selenium


【解决方案1】:

您的 chrome 驱动程序不支持您的 chrome 浏览器版本。 chromedriver 2.38 支持 v65-67。所以这似乎是一个配置问题。使用下面安装最新版本的 chrome 驱动程序。

http://chromedriver.chromium.org/downloads

【讨论】:

  • 这似乎已经解决了,至少现在是这样。非常感谢!
猜你喜欢
  • 2012-07-20
  • 2015-08-13
  • 2013-04-06
  • 1970-01-01
  • 1970-01-01
  • 2017-05-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多