【发布时间】: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版本?