Selenium ChromeDriver-driver.quit()上的HTTP 407 [英] Selenium ChromeDriver - HTTP 407 on driver.quit()

查看:132
本文介绍了Selenium ChromeDriver-driver.quit()上的HTTP 407的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在代理服务器后面.使用Selenium 2.39,Python 2.7.6和ChromeDriver 2.9,每当我在Chrome实例上调用.quit()时,都会收到HTTP 407错误.使用FirefoxDriver时不会发生此类错误.

I am behind a proxy server. Using Selenium 2.39, Python 2.7.6 and ChromeDriver 2.9, whenever I call .quit() on an instance of Chrome, I get an HTTP 407 error. No such error occurs when using FirefoxDriver.

Traceback (most recent call last):
File "C:\Users\Tetrinity\Desktop\chrometest.py", line 7, in <module>
    browser.quit()
  File "C:\Python27\lib\site-packages\selenium-2.39.0-py2.7.egg\selenium\webdriver\chrome\webdriver.py", line 82, in quit
    self.service.stop()
  File "C:\Python27\lib\site-packages\selenium-2.39.0-py2.7.egg\selenium\webdriver\chrome\service.py", line 97, in stop
    url_request.urlopen("http://127.0.0.1:%d/shutdown" % self.port)
  File "C:\Python27\lib\urllib2.py", line 127, in urlopen
    return _opener.open(url, data, timeout)
  File "C:\Python27\lib\urllib2.py", line 410, in open
    response = meth(req, response)
  File "C:\Python27\lib\urllib2.py", line 523, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Python27\lib\urllib2.py", line 448, in error
    return self._call_chain(*args)
  File "C:\Python27\lib\urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "C:\Python27\lib\urllib2.py", line 531, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 407: Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy service is denied.  )

问题可以简化为以下脚本,我将其保存为chrometest.py(如上面的堆栈跟踪所示):

The problem can be reduced to the following script, which I have saved as chrometest.py (as seen in the above stacktrace):

from selenium import webdriver
browser = webdriver.Chrome()
browser.get("http://www.google.co.uk")
browser.quit()

此脚本成功打开了Chrome并导航到Google.然后.quit()导致上述崩溃,并留下死掉的ChromeDriver实例.可能是什么原因造成的,我该如何预防?

This script successfully opens Chrome and navigates to Google. The .quit() then causes the above crash, leaving a dead ChromeDriver instance lying around. What could be causing this, and how can I prevent it?

研究发现了很多答案,事情太复杂了声称这是已经解决的问题.

Research has turned up a lot of answers that aren't quite relevant, overcomplicate things or claim it's an issue that was already fixed.

推荐答案

由于我今天浪费了数小时试图寻找解决方案,所以我认为自己应该记录下对我有用的文件.我通过打开"Internet选项">连接">"LAN设置">高级"并将127.0.0.1插入例外"框中来解决此问题.完成此操作后,chrometest.py正确完成,ChromeDriver窗口已成功关闭.

Since I wasted several hours today trying to track down a solution, I thought I'd document what worked for me. I fixed this problem by opening Internet Options > Connections > LAN settings > Advanced and inserting 127.0.0.1 into the Exceptions box. After doing this, chrometest.py completed without error and the ChromeDriver window was successfully closed.

此解决方案的信用应转到提问者

Credit for this solution should go to the question-asker here. Oddly enough, this question never appeared in my searches. It appeared in the Similar Questions section when I was nearly finished typing up the original version of this question (go figure!).

这篇关于Selenium ChromeDriver-driver.quit()上的HTTP 407的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆