问题
I started messing around with Python networking using selenium on Firefox. Unfortunately, I keep getting "ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine".
However, this only happens when running some commands, and it only happens the first time I run them. If execute the command a second time right after that, it works. (See below for a minimal example.)
I found this question, but being a networking newbie I'm having a hard time applying the solution to my situation. How do I prevent the connection from shutting down?
Any help is greatly appreciated!
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://www.google.com/')
searchfield = browser.find_element_by_id("lst-ib") # Runs without issues
searchfield.get_attribute("value") # Produces WinError 10053
searchfield.get_attribute("value") # Returns '' as it should
EDIT: It seems the error only occurs, when I execute the command in the shell, rather than saving and running the whole script. Nonetheless, it's pretty annoying.
回答1:
I got the same problem, my config is: Firefox 60.0.2 (64 bits) ; geckodriver 0.21.0 ( 64 bits) ; selenium 3.12.0
I resolved this problem by downgrade geckodriver to 0.20.1 ( 64 bits)
回答2:
I had the same problem and tried solutions that were mentioned here but nothing helped me. In the end, it was a very simple solution:
copy the script and the geckodriver to a different folder, and then run it from there. I suppose that in the folder where I always worked I had logs that generated conflicts and that's why this solution worked.
来源:https://stackoverflow.com/questions/50996452/python-selenium-winerror-10053-host-is-shutting-connection-down