When learning selenium, if sleep time is greater than or equal to 5 seconds, it will prompt connectionreseterror: [Errno] Connection reset by peer.
Switch to Chrome to work.
#demo. pyFromSeleniumImportWebdriverFromTimeImportSleep,CTime#chrome#driver = Webdriver. Chrome (executable_path= '//users/csj/desktop/seleniumdriver/chromedriver/chromedriver ')#Firefoxdriver 21.0Driver=Webdriver.Firefox(Executable_path='//users/csj/desktop/seleniumdriver/firefoxdriver/21.0/geckodriver ')#Firefoxdriver 20.1#driver = Webdriver. Firefox (executable_path= '//users/csj/desktop/seleniumdriver/firefoxdriver/20.1/geckodriver ')#Firefoxdriver 20.0#driver = Webdriver. Firefox (executable_path= '//users/csj/desktop/seleniumdriver/firefoxdriver/20.0/geckodriver ')#Firefox 19.1#driver = Webdriver. Firefox (executable_path= '//users/csj/desktop/seleniumdriver/firefoxdriver/19.1/geckodriver ')Driver.Implicitly_wait(10)Driver.Get("Http://www.baidu.com")Print(CTime())Sleep(5)Print(CTime())Driver.find_element_by_id("KW").Send_keys("Selenium")Driver.Close()```UseFirefoxdriver21.0, report the following error:Traceback(MostRecentPagerLast):File"/users/csj/pycharmprojects/untitled/demo.py",Line13,Inch<Module>Driver.find_element_by_id("KW").Send_keys("Selenium")File"/users/csj/anaconda/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py",Line353,Inchfind_element_by_idReturnSelf.Find_element(By=By.Id,Value=Id_)File"/users/csj/anaconda/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py",Line957,InchFind_element' Value ':Value})[' Value ']File"/users/csj/anaconda/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py",Line312,InchExecuteResponse=Self.Command_executor.Execute(Driver_command,Params)File"/users/csj/anaconda/lib/python3.6/site-packages/selenium/webdriver/remote/remote_connection.py",Line472,InchExecuteReturnSelf._request(Command_info[0],Url,Body=Data)File"/users/csj/anaconda/lib/python3.6/site-packages/selenium/webdriver/remote/remote_connection.py",Line496,Inch_requestResp=Self._conn.GetResponse()File"/users/csj/anaconda/lib/python3.6/http/client.py",Line1331,InchGetResponseResponse.Begin()File"/users/csj/anaconda/lib/python3.6/http/client.py",Line297,InchBeginVersion,Status,Reason=Self._read_status()File"/users/csj/anaconda/lib/python3.6/http/client.py",Line258,Inch_read_statusLine=Str(Self.Fp.ReadLine(_maxline+1),"Iso-8859-1")File"/users/csj/anaconda/lib/python3.6/socket.py",Line586,InchReadintoReturnself. _sock. Recv_into (b) connectionreseterror : [errno 54] Connection reset by peer replace firefox 20.120.0 19.1, can be run successfully without prompting sleep time set to 10 seconds, no more error.
Python3+selenium 3.13 + geckodriver 21.0, prompt for connectionreseterror, toggle lower version of driver