J'essaie d'ouvrir un site Web sur chrome en utilisant Python Selenium chromedriver. Chrome s'ouvre (avec des avertissements) et l'url ne s'ouvre pas.
Détails de la version: Chrome: 68.0.3440.106 Selenium: 3.14.0 chromedriver: 2.20 python: 2.7
J'utilise le code ci-dessous:
import time
from Selenium import webdriver
import Selenium
driver = webdriver.Chrome("C:/Python27/chromedriver.exe")
driver.get("https://vancouver.craigslist.ca/")
print(driver.title)
time.sleep(8)
driver.quit()
J'obtiens en dessous de l'erreur:
C:\Users\sohil7777\PycharmProjects\temp.py\venv\Scripts\python.exe C:/Users/sohil7777/.PyCharmCE2018.2/config/scratches/scratch.py
Traceback (most recent call last):
File "C:/Users/sohil7777/.PyCharmCE2018.2/config/scratches/scratch.py", line 6, in <module>
driver = webdriver.Chrome("C:/Python27/chromedriver.exe")
File "C:\Python27\lib\site-packages\Selenium\webdriver\chrome\webdriver.py", line 75, in __init__
desired_capabilities=desired_capabilities)
File "C:\Python27\lib\site-packages\Selenium\webdriver\remote\webdriver.py", line 156, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Python27\lib\site-packages\Selenium\webdriver\remote\webdriver.py", line 251, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Python27\lib\site-packages\Selenium\webdriver\remote\webdriver.py", line 318, in execute
response = self.command_executor.execute(driver_command, params)
File "C:\Python27\lib\site-packages\Selenium\webdriver\remote\remote_connection.py", line 375, in execute
return self._request(command_info[0], url, body=data)
File "C:\Python27\lib\site-packages\Selenium\webdriver\remote\remote_connection.py", line 397, in _request
resp = self._conn.request(method, url, body=body, headers=headers)
File "C:\Python27\lib\site-packages\urllib3\request.py", line 72, in request
**urlopen_kw)
File "C:\Python27\lib\site-packages\urllib3\request.py", line 150, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "C:\Python27\lib\site-packages\urllib3\poolmanager.py", line 322, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "C:\Python27\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Python27\lib\site-packages\urllib3\util\retry.py", line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Python27\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "C:\Python27\lib\site-packages\urllib3\connectionpool.py", line 377, in _make_request
httplib_response = conn.getresponse(buffering=True)
File "C:\Python27\Lib\httplib.py", line 1121, in getresponse
response.begin()
File "C:\Python27\Lib\httplib.py", line 438, in begin
version, status, reason = self._read_status()
File "C:\Python27\Lib\httplib.py", line 394, in _read_status
line = self.fp.readline(_MAXLINE + 1)
File "C:\Python27\Lib\socket.py", line 480, in readline
data = self._sock.recv(self._rbufsize)
urllib3.exceptions.ProtocolError: ('Connection aborted.', error(10054, 'An existing connection was forcibly closed by the remote Host'))
Suis-je en train de manquer quelque chose? J'apprécie vraiment votre aide
Ce message d'erreur ...
urllib3.exceptions.ProtocolError: ('Connection aborted.', error(10054, 'An existing connection was forcibly closed by the remote Host'))
... implique que le ChromeDriver n'a pas pu lancer/générer un nouveau WebBrowser ie session du navigateur Chrome .
Votre problème principal est l'incompatibilité entre la version des binaires que vous utilisez comme suit:
Prise en charge Chrome v43-48
Prise en charge Chrome v67-69
Il y a donc un décalage évident entre ChromeDriver v2.33 et le navigateur Chrome v65.0
@Test
.