Selenium WebDriverException:已达到错误页面

问题描述 投票:7回答:5

我正在关注Django TDD教程: http://www.marinamele.com/taskbuster-django-tutorial/taskbuster-working-environment-and-start-django-project 在我启动开发服务器'python manage.py runserver'之前和之后运行'all_users.py'时出现以下错误:

回溯(最近一次调用最后一次):文件“functional_tests / all_users.py”,第15行,在test_it_worked self.browser.get('http://localhost:8000')文件“/Users/samgao/.virtualenvs/tb_test/lib/python3.6/ site-> packages / selenium / webdriver / remote / webdriver.py“,第264行,在get self.execute(Command.GET,{'url':url})文件”/Users/samgao/.virtualenvs/tb_test/lib /python3.6/site->packages/selenium/webdriver/remote/webdriver.py“,第252行,执行self.error_handler.check_response(响应)文件”/Users/samgao/.virtualenvs/tb_test/lib/python3。 6 / site-> packages / selenium / webdriver / remote / errorhandler.py“,第194行,在check_response中引发exception_class(消息,屏幕,堆栈跟踪)selenium.common.exceptions.WebDriverException:消息:已达到错误页面:> about:neterror E = connectionFailure&U = HTTP%3A //本地主机%3A8000 /& C = UTF-> 8 F =定期&d =火狐%20can%E2%80%99吨%20establish%20A%20connection%20to%第二十条%20S> erver%20AT%20localhost %3A8000。

基本上无法建立与localhost的连接。 设置和配置与上一个链接中的教程相同。

我已经在这个问题上苦苦挣扎了两天,如果你能提供任何帮助,我会非常友好地感谢你。

firefox selenium-webdriver python-3.6 django-1.8
5个回答
3
投票

我遇到了同样的问题,最终的解决方案是:重新安装geckodriver

  1. 解压缩geckodriver.zip
  2. 将文件移动到/usr/bin目录sudo mv geckodriver /usr/bin
  3. 转到/ usr / bin目录cd / usr / bin,然后你需要运行类似sudo chmod a+x geckodriver的东西来标记它的可执行文件。

1
投票

这可能不是你的情况,但我在运行测试(同一本书,嘿嘿)时得到了相同的错误消息,而没有任何实际监听目标端口(在我的情况下为8000)。通过手动打开浏览器并转到localhost:8000,确保有一些内容正在侦听请求。在我的情况下 - 愚蠢的我 - 我根本没有服务器=)


1
投票

我得到了同样的错误,为我解决的是从localhost更改为127.0.0.1:

  • 老:self.browser.get('http://localhost:8000')
  • 更好:self.browser.get('http://127.0.0.1:8000')

0
投票

因为这是“服从测试山羊”的快照(在Django 1.8的时间周围) - 也许这些说明不再相关。我建议going straight to the goat's mouth并重新开始!

该问题可能与virtualenvwrapper(不再需要)有关,或者可能与您尝试访问的端口/地址有关。取决于您的Selenium和Firefox there may be issues related to that as well的版本。


0
投票

我也遵循相同的教程并遇到了同样的错误。我注意到我没有运行django服务器。以下是有帮助的。

python manage.py runserver
python functional_test.py
© www.soinside.com 2019 - 2024. All rights reserved.