#python #selenium
#python #селен
Вопрос:
итак, в моем коде на python сначала я захожу на другой веб-сайт и загружаю файл с помощью selenium,
завершаю selenium, выполнив driver.quit(), а затем в качестве следующего шага я загружаю файл из Smartsheet ,
похоже, что smartsheet повторно использует сеанс, который я установил ранее в selenium
код работает нормально независимо
import smartsheet
import json
access_token=''
download_directory_path='c:\Incoming\'
# Initialize client
smartsheet_client = smartsheet.Smartsheet(access_token)
contents = json.loads(str(smartsheet_client.Home.list_all_contents(include='source')))
smartsheet_client.Sheets.get_sheet_as_excel(1829801544705924,download_directory_path)
# Make sure we don't miss any errors
smartsheet_client.errors_as_exceptions(True)
трассировка стека
Traceback (most recent call last):
File "C:Program FilesPython36libsite-packagesurllib3connection.py", line 170, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File "C:Program FilesPython36libsite-packagesurllib3utilconnection.py", line 96, in create_connection
raise err
File "C:Program FilesPython36libsite-packagesurllib3utilconnection.py", line 86, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:Program FilesPython36libsite-packagesurllib3connectionpool.py", line 706, in urlopen
chunked=chunked,
File "C:Program FilesPython36libsite-packagesurllib3connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "C:Program FilesPython36libsite-packagesurllib3connection.py", line 234, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "C:Program FilesPython36libhttpclient.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:Program FilesPython36libhttpclient.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:Program FilesPython36libhttpclient.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:Program FilesPython36libhttpclient.py", line 1026, in _send_output
self.send(msg)
File "C:Program FilesPython36libhttpclient.py", line 964, in send
self.connect()
File "C:Program FilesPython36libsite-packagesurllib3connection.py", line 200, in connect
conn = self._new_conn()
File "C:Program FilesPython36libsite-packagesurllib3connection.py", line 182, in _new_conn
self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x0000023D8D213D68>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "downloadfile.py", line 108, in <module>
Downloadfile()
File "downloadfile.py", line 77, in DownloadAggdata
cell_text = driver.find_element_by_xpath(FinalXPath).text
File "C:Program FilesPython36libsite-packagesseleniumwebdriverremotewebdriver.py", line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:Program FilesPython36libsite-packagesseleniumwebdriverremotewebdriver.py", line 978, in find_element
'value': value})['value']
File "C:Program FilesPython36libsite-packagesseleniumwebdriverremotewebdriver.py", line 319, in execute
response = self.command_executor.execute(driver_command, params)
File "C:Program FilesPython36libsite-packagesseleniumwebdriverremoteremote_connection.py", line 374, in execute
return self._request(command_info[0], url, body=data)
File "C:Program FilesPython36libsite-packagesseleniumwebdriverremoteremote_connection.py", line 397, in _request
resp = self._conn.request(method, url, body=body, headers=headers)
File "C:Program FilesPython36libsite-packagesurllib3request.py", line 79, in request
method, url, fields=fields, headers=headers, **urlopen_kw
File "C:Program FilesPython36libsite-packagesurllib3request.py", line 170, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "C:Program FilesPython36libsite-packagesurllib3poolmanager.py", line 375, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "C:Program FilesPython36libsite-packagesurllib3connectionpool.py", line 796, in urlopen
**response_kw
File "C:Program FilesPython36libsite-packagesurllib3connectionpool.py", line 796, in urlopen
**response_kw
File "C:Program FilesPython36libsite-packagesurllib3connectionpool.py", line 796, in urlopen
**response_kw
File "C:Program FilesPython36libsite-packagesurllib3connectionpool.py", line 756, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "C:Program FilesPython36libsite-packagesurllib3utilretry.py", line 573, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=56988): Max retries exceeded with url: /session/5b42bcd2457bb5dce275ba3720168b1e/element (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000023D8D213D68>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',))
Комментарии:
1. «/session/5b42bcd2457bb5dce275ba3720168b1e/element» — это вызов Selenium webdriver для браузера. (Проводной протокол …) Исключение там предполагает, что выполняется вызов браузера, который больше не открыт. Исправьте эту часть и посмотрите, поможет ли это… Файл «downloadfile.py «, строка 77
2. Спасибо.. так оно и было ..