# 1. Language/🌊 Python

셀레니움(Selenium) # ElementNotInteractableException Message: element not interactable에러

둥굴둥굴둥굴레차 2021. 8. 18. 18:09

상황

셀레니움으로 스크래핑을 하다가 ElementNotInteractableException Message: element not interactable 에러를 만났다.

내가 만났던 에러는 아래와 같다.

Traceback (most recent call last): 
...
(생략)
...
self.error_handler.check_response(response) File "C:\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable (Session info: chrome=92.0.4515.131)

 

에러 발생 이유

영어로 구글링 해보니 다음과 같은 이유로 에러가 발생한다는 것을 알게 되었다.

When a web element is present in the HTML DOM but it is not in the state that can be interacted. In other words when element is found but we can’t interact with it, then it throws ElementNotInteractableException.

엘리먼트가 HTML DOM에 존재하지만 선언이 되지 않았거나 상호작용할 수 없을 때.

즉, 엘리먼트를 찾을 수는 있으나 우리가 상호작용할 수 없을 때 ElementNotInteractableException를 뱉는다.

 

해결

음.. 에러의 이유는 이러한데 결국 에러를 해결한 방법 .click()이 아닌 send_keys(Keys.ENTER)를 사용하여 클릭하니 잘 돌아갔다.

그런데 이미지는 반드시 click()을 써야 해서 일단 이미지를 제외한 나머지를 send_keys(Keys.ENTER)로 바꾼 후 돌렸다. 그래서 이미지는 여전히 click()이기 때문에 다시 에러를 뱉을까 걱정되었지만 이상하게 잘되었다..😲 뭐지 뭐지~~??

 

...

오늘도 알 수 없는 하루였다..ㅎ

 

 


🔽 REFERENCE

 

How To Resolve Element Not Interactable Exception Selenium

In this tutorial, we will learn what is element not interactable exception, How to resolve this exception. In Selenium, this is common to face any exception to finding the web element.

automationtestings.com