2

我在代理服務器後面。使用Selenium 2.39,Python 2.7.6和ChromeDriver 2.9,只要我在Chrome實例上調用.quit(),就會得到HTTP 407錯誤。使用FirefoxDriver時不會出現此類錯誤。Selenium ChromeDriver - driver.quit上的HTTP 407()

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(如上面的堆棧跟蹤看到):

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

這個腳本成功打開瀏覽器並導航到谷歌。 .quit()然後導致上面的崩潰,留下一個死的ChromeDriver實例。有什麼可能導致這種情況,我該如何預防它?

研究發現了很多答案aren't quite relevant,overcomplicate thingsclaim it's an issue that was already fixed

回答

3

因爲我今天浪費了幾個小時試圖追蹤解決方案,我以爲我會記錄什麼對我有用。我通過打開Internet選項>連接> LAN設置>高級並將127.0.0.1插入到例外框中解決了此問題。完成此操作後,chrometest.py無錯地完成,並且ChromeDriver窗口已成功關閉。

此解決方案的信用應轉到提問者here。奇怪的是,這個問題從來沒有出現在我的搜索。當我幾乎完成了這個問題的原始版本的輸入時,它出現在類似問題部分(去圖!)。

+0

我給出了圖片格式的相同輸出。感謝您的幫助。 –

1

這是Chrome瀏覽器的問題。以下步驟將爲您提供修復。

1 |取消選中該複選框,By Proxy server for local address

enter image description here

2 |點擊高級選項卡

enter image description here

3 |在例外面板下輸入127.0.0.1

4 |點擊確定

相關問題