ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine with GeckoDriver and Firefox
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine with GeckoDriver and Firefox
我正在使用下面的 python 脚本登录 Fedex 跟踪服务
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from time import sleep
driver = webdriver.Firefox()
driver.get("https://www.fedex.com/apps/fedextracking/?cntry_code=us&locale=us_en#")
sleep(5)
users = driver.find_element_by_xpath("//div[@class='fxg-field'][1]/input[@class='fxg-field__input-text']")
users.send_keys('test')
passwords = driver.find_element_by_xpath("//input[@id='pswd-input']")
passwords.send_keys('test')
sleep(3)
submit = driver.find_element_by_xpath("//button[@id='login']")
submit.click()
它没有显示确切的错误,而是显示了这些错误:
File "test.py", line 10, in <module>
users = driver.find_element_by_xpath("//div[@class='fxg-field'][1]/input[@class='fxg-field__input-text']")
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 393, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 966, in find_element 'value': value})['value']
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 318, in execute
response = self.command_executor.execute(driver_command, params)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 472, in execute
return self._request(command_info[0], url, body=data)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 495, in _request
self._conn.request(method, parsed_url.path, body, headers)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 1083, in request
self._send_request(method, url, body, headers)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 1128, in _send_request
self.endheaders(body)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 1079, in endheaders
self._send_output(message_body)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 913, in _send_output
self.send(message_body)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 885, in send
self.sock.sendall(data)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
它在 Google Chrome 上运行流畅,但不适用于 Firefox。请帮我解决这个问题。
编辑
Firefox 版本57.0.4 (64-bit)
硒版本3.13.0
壁虎司机0.21.0
更新
问题只出在这个网站上。我尝试了其他跟踪站点,它们都使用 Firefox。此特定站点不适用于 Firefox。
这可能与您使用的 Firefox 版本有关。检查 selenium 支持哪些 Firefox 浏览器版本。 https://www.seleniumhq.org/about/platforms.jsp.
Support for Firefox is the latest release, the previous release, the
latest ESR release and the previous ESR release.
For example Selenium 2.40.0 (released on Feb 19, 2014) supports
Firefox 27, 26, 24, 17
Selenium with Firefox can be run on any platform that Firefox supports
for those versions, that also allow users to install a custom Firefox
extension.
而不是使用
driver.find_element_by_xpath("//div[@class='fxg-field'][1]/input[@class='fxg-field__input-text']")
试试
driver.find_element_by_xpath(//input[@name="USER"])
您的代码块近乎完美。我采用了您自己的代码并进行了一些调整,其中包括在 USER ID 字段上调用 send_keys()
之前引入 WebDriverWait,如下所示:
代码块:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Firefox(executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe')
driver.get("https://www.fedex.com/apps/fedextracking/?cntry_code=us&locale=us_en#")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@class='fxg-field__input-text' and @name='USER']"))).send_keys('test')
driver.find_element_by_xpath("//input[@class='fxg-field__input-text' and @name='PASSWORD']").send_keys('test')
driver.find_element_by_xpath("//button[@class='fxg-button fxg-button--orange' and @name='login']/span").click()
浏览器快照:
USER ID
和 PASSWORD
字段正在填写:
- 凭据错误导致错误:
我正在使用下面的 python 脚本登录 Fedex 跟踪服务
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from time import sleep
driver = webdriver.Firefox()
driver.get("https://www.fedex.com/apps/fedextracking/?cntry_code=us&locale=us_en#")
sleep(5)
users = driver.find_element_by_xpath("//div[@class='fxg-field'][1]/input[@class='fxg-field__input-text']")
users.send_keys('test')
passwords = driver.find_element_by_xpath("//input[@id='pswd-input']")
passwords.send_keys('test')
sleep(3)
submit = driver.find_element_by_xpath("//button[@id='login']")
submit.click()
它没有显示确切的错误,而是显示了这些错误:
File "test.py", line 10, in <module>
users = driver.find_element_by_xpath("//div[@class='fxg-field'][1]/input[@class='fxg-field__input-text']")
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 393, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 966, in find_element 'value': value})['value']
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 318, in execute
response = self.command_executor.execute(driver_command, params)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 472, in execute
return self._request(command_info[0], url, body=data)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 495, in _request
self._conn.request(method, parsed_url.path, body, headers)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 1083, in request
self._send_request(method, url, body, headers)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 1128, in _send_request
self.endheaders(body)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 1079, in endheaders
self._send_output(message_body)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 913, in _send_output
self.send(message_body)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 885, in send
self.sock.sendall(data)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
它在 Google Chrome 上运行流畅,但不适用于 Firefox。请帮我解决这个问题。
编辑
Firefox 版本57.0.4 (64-bit)
硒版本3.13.0
壁虎司机0.21.0
更新
问题只出在这个网站上。我尝试了其他跟踪站点,它们都使用 Firefox。此特定站点不适用于 Firefox。
这可能与您使用的 Firefox 版本有关。检查 selenium 支持哪些 Firefox 浏览器版本。 https://www.seleniumhq.org/about/platforms.jsp.
Support for Firefox is the latest release, the previous release, the latest ESR release and the previous ESR release.
For example Selenium 2.40.0 (released on Feb 19, 2014) supports Firefox 27, 26, 24, 17
Selenium with Firefox can be run on any platform that Firefox supports for those versions, that also allow users to install a custom Firefox extension.
而不是使用
driver.find_element_by_xpath("//div[@class='fxg-field'][1]/input[@class='fxg-field__input-text']")
试试
driver.find_element_by_xpath(//input[@name="USER"])
您的代码块近乎完美。我采用了您自己的代码并进行了一些调整,其中包括在 USER ID 字段上调用 send_keys()
之前引入 WebDriverWait,如下所示:
代码块:
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC driver = webdriver.Firefox(executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe') driver.get("https://www.fedex.com/apps/fedextracking/?cntry_code=us&locale=us_en#") WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@class='fxg-field__input-text' and @name='USER']"))).send_keys('test') driver.find_element_by_xpath("//input[@class='fxg-field__input-text' and @name='PASSWORD']").send_keys('test') driver.find_element_by_xpath("//button[@class='fxg-button fxg-button--orange' and @name='login']/span").click()
浏览器快照:
USER ID
和PASSWORD
字段正在填写:
- 凭据错误导致错误: