반응형
Selenium 사용 시 아래와 같은 경고 메시지가 표시되는 경우가 있다.
WARNING:urllib3.connectionpool:Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000229B1AA7FD0>: Failed to establish a new connection: [WinError 10061] 대상 컴퓨터에서 연결을 거부했으므로 연결하지 못했습니다')': /session/bf8000eff591a4e17810d9d23c3c91cc/window/handles
WARNING:urllib3.connectionpool:Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000229B1AC3760>: Failed to establish a new connection: [WinError 10061] 대상 컴퓨터에서 연결을 거부했으므로 연결하지 못했습니다')': /session/bf8000eff591a4e17810d9d23c3c91cc/window/handles
WARNING:urllib3.connectionpool:Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000229B1AC3280>: Failed to establish a new connection: [WinError 10061] 대상 컴퓨터에서 연결을 거부했으므로 연결하지 못했습니다')': /session/bf8000eff591a4e17810d9d23c3c91cc/window/handles
이유는 selenium 의 webdriver 선언을 한 후 반복문에 들어간 후 quit() 로 닫았다가 다시 시도를 하는 경우 발생한다.
driver = webdriver.Chrome('./chromedriver', chrome_options=options)
for i in range(1, 100):
driver.get("https://url.com")
driver.quit()
이런 경우 발생한다.
해결방법은 다음과 같이 webdriver 선언을 반복문 안으로 넣으면 된다.
for i in range(1, 100):
driver = webdriver.Chrome('./chromedriver', chrome_options=options)
driver.get("https://url.com")
driver.quit()
반응형