[英]Selenium ChromeDriver - HTTP 407 on driver.quit()
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. 使用Selenium 2.39,Python 2.7.6和ChromeDriver 2.9,每当我在Chrome实例上调用.quit()
时,都会收到HTTP 407错误。 No such error occurs when using FirefoxDriver. 使用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. )
The problem can be reduced to the following script, which I have saved as chrometest.py
(as seen in the above stacktrace): 可以将问题简化为以下脚本,我将其保存为chrometest.py
(如上述chrometest.py
所示):
from selenium import webdriver
browser = webdriver.Chrome()
browser.get("http://www.google.co.uk")
browser.quit()
This script successfully opens Chrome and navigates to Google. 此脚本成功打开Chrome并导航到Google。 The .quit()
then causes the above crash, leaving a dead ChromeDriver instance lying around. 然后, .quit()
导致上述崩溃,并留下死掉的ChromeDriver实例。 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 . 研究已经发现了许多不太相关的答案,使问题变得 过于复杂或声称这是已经解决的问题 。
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. 我通过打开“ Internet选项”>“连接”>“ LAN设置”>“高级”并将“ 127.0.0.1
插入“例外”框中来解决此问题。 After doing this, chrometest.py
completed without error and the ChromeDriver window was successfully closed. 完成此操作后, chrometest.py
完成,并且ChromeDriver窗口已成功关闭。
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!). 当我快要完成此问题的原始版本的输入时,它出现在“相似问题”部分。
This is an issue on Chrome browser. 这是Chrome浏览器上的问题。 The following steps will give you the fix. 以下步骤将为您提供修复程序。
1| 1 | Uncheck the Check Box, By Proxy server for local address
取消选中“ By Proxy server for local address
”复选框By Proxy server for local address
2| 2 | Click on Advanced Tab 单击高级选项卡
3| 3 | Enter 127.0.0.1
under Exceptions panel 在“例外”面板下输入127.0.0.1
4| 4 | Click ok 点击确定
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.