Answer the question
In order to leave comments, you need to log in
How to stop a loop with selenium?
I have a loop in which actions are performed with selenium.
while loopflag:
driver.get(link)
element = driver.find_elements(By.CLASS_NAME, "annonces_entry_link")
if ads_reg.lower() == "нет":
print("net")
else:
driver.quit()
loopflag = False
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=50081): Max retries exceeded with url: /session/2979bc01b96dcad71567dd73a8aac239/element (Caused by NewConnectionError( ': Failed to establish a new connection: [WinError 10061] The connection failed because the destination computer refused the connection request'))
Answer the question
In order to leave comments, you need to log in
wrap the while in a try...except and catch the called exception. in except block - stop selenium
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question