简体   繁体   English

Selenium ChromeDriver-driver.quit()上的HTTP 407

[英]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.

相关问题 在 driver.quit 后调用 chromedriver 不起作用? - Invoking chromedriver after driver.quit not working? python selenium driver.quit() 里面除了块 - python selenium driver.quit() inside except block python selenium driver.quit() 不会中途终止程序 - python selenium driver.quit() won't terminate the program midway 如果设置了firefox_profile,则python selenium driver.quit()无法退出firefox浏览器 - python selenium driver.quit() can not quit firefox browser if firefox_profile setted Selenium 中的 driver.quit():ConnectionRefusedError 如果用于多个驱动程序 object - driver.quit() in Selenium : ConnectionRefusedError if used on more than one driver object 尽管 driver.close 和 driver.quit,IDLE 不会终止我的 selenium 浏览器 - IDLE doesn't terminate my selenium broswer despite driver.close and driver.quit 硒3.0.2中的driver.quit firefox 50.1.0 firefox已停止工作 - driver.quit in selenium 3.0.2 firefox 50.1.0 firefox has stopped working Selenium:如何在不调用 driver.quit() 的情况下停止影响 PC 内存的 geckodriver 进程? - Selenium : How to stop geckodriver process impacting PC memory, without calling driver.quit()? driver.quit() 在未处理的异常之后 - driver.quit() after unhandled exception 在所有情况下调用 driver.quit() - invoke driver.quit() in all cases
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM