일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- 쿼리
- OS
- Python
- os.path
- ds_store
- sort v.s. sorted
- [초급(예비) 개발자 오픈소스 실무 역량강화 교육]
- blinker
- 함수형 프로그래밍
- reverse v.s. reversed
- 코딩 테스트
- decorator
- 생각
- CI/CD
- timestamp
- 순수함수
- selenium-wire
- pandas
- boto3
- functools.wraps
- S3
- r-string
- 고차함수
- Airflow
- slicing [::-1]
- sort(reverse=True) v.s. reverse
- PIP
- Today
- Total
공부일지
[Python]selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable 본문
[Python]selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
이르리의 공부일지 2023. 10. 16. 11:55크롤러에 element 연결이 안 된다는 오류가 있었다.
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
해결한 줄 알았는데 해결이 안 됐다.
그래서 다음과 같은 시도 끝에 문제를 해결했다.
1. 크롬 및 크롬 드라이버 업뎃
2. .click() → .send_keys()
3. .send_keys() → .execute_script() >>해결!
처음 오류
Traceback (most recent call last):
File "/Users/yeolmaecompany/Desktop/auction_solution_crawler/crawler.py", line 64, in <module>
df, kinds = auc.main(driver, df)
^^^^^^^^^^^^^^^^^^^^
File "/Users/yeolmaecompany/Desktop/auction_solution_crawler/auction/SeoulAuction.py", line 442, in main
driver.find_element_by_xpath("//*[@class='utility-login']").click()
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/selenium/webdriver/remote/webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/selenium/webdriver/remote/webelement.py", line 693, in _execute
return self._parent.execute(command, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 418, in execute
self.error_handler.check_response(response)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
(Session info: chrome=117.0.5938.149)
크롬 드라이버도 업뎃하고 .click()에서 .send_keys()로 바꾼 뒤에도 뜬 오류
Traceback (most recent call last):
File "/Users/yeolmaecompany/Desktop/auction_solution_crawler/crawler.py", line 64, in <module>
df, kinds = auc.main(driver, df)
^^^^^^^^^^^^^^^^^^^^
File "/Users/yeolmaecompany/Desktop/auction_solution_crawler/auction/SeoulAuction.py", line 449, in main
driver.find_element_by_xpath("//*[@class='utility-login']").send_keys(Keys.ENTER)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/selenium/webdriver/remote/webelement.py", line 539, in send_keys
self._execute(Command.SEND_KEYS_TO_ELEMENT,
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/selenium/webdriver/remote/webelement.py", line 693, in _execute
return self._parent.execute(command, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 418, in execute
self.error_handler.check_response(response)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
(Session info: chrome=118.0.5993.70)
해결방법
login = driver.find_element_by_xpath("//*[@class='utility-login']/a[1]")
driver.execute_script("arguments[0].click();", login)
# driver.find_element_by_xpath("//*[@class='utility-login']/a[1]").send_keys(Keys.ENTER)
# driver.find_element_by_xpath("//*[@class='utility-login']").click()
주석처럼
여러번의 시도 끝에 해결했다.
참고 블로그들
1) 코드 수정
최종 시도: .execute_script() 이용
How to fix this issue element not interactable Selenium Python
I have the following line in my script code, where the XPath I got it from Selenium IDE that works fine: driver.find_element_by_xpath("(//a[contains(@href, '')])[20]").click() An automation test ...
stackoverflow.com
위 방법으로 적용해서 최종적으로 해결했다!
해당 코드는 아래와 같다.
(다른 방법은 왜 안 됐는지 잘 모르겠다.)
login = driver.find_element_by_xpath("//*[@class='utility-login']/a[1]")
driver.execute_script("arguments[0].click();", login)
시도: .send_keys() 이용
https://letsstudylog.tistory.com/89
[Python]selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable 크롤러에서 발생한 오류이다. .click() → .send_keys(Keys.ENTER) 하면 해결되는 오류이다. .send_keys를 쓰려면 아래와 같이 import 해
letsstudylog.tistory.com
내 블로그에 써놨음.
예전에 같은 에러일 때 해결했었는데 이번에는 안 됐다.
driver.find_element_by_xpath("//*[@class='utility-login']/a[1]").send_keys(Keys.ENTER)
2) 맨 처음 시도: Chrome 업뎃 및 chromedriver 새로 설치
https://letsstudylog.tistory.com/73
[Selenium]크롬 버전 확인 및 크롬 드라이버 설치
크롬 버전 확인하기 ▼ 크롬-크롬 맞춤설정 및 제어(우측 상단 점 세개 버튼)-설정-Chrome 정보 혹은 url 창에 chrome://version/ 쳐서 확인 크롬 드라이버 설치 ▼ ~114 버전 https://chromedriver.chromium.org/downlo
letsstudylog.tistory.com
처음에 오류를 보고
크롬 드라이버 버전 문제인가 싶어서 새로 다운로드해서 프로젝트 폴더에 집어넣었다.
그랬더니,
'개발자를 확인할 수 없기 때문에 'chromedriver'을(를) 열 수 없습니다.' 라는 안내문구가 떴다.
아래는 해당 오류 해결 하기 위해 참고한 블로그 들이다.
[Python활용] Chrome Driver 설치 및 Selenium 활용
안녕하세요 ! 이번 포스팅에서는 Python을 활용하기 위한 준비로 웹크롤링을 하기 위한 Chrome Driver 설치와 Selenium의 활용법에 대한 포스팅을 준비해보았습니다. Chrome Driver 설치 및 Selenium 활용 먼저
wg-cy.tistory.com
요약: 환경설정 옵션 수정
결과: 해결 X
환경 설정 > 보안 및 개인정보 보호 > 개인정보 보호 > 개발자 도구 > 터미널 옵션 체크(자물쇠 연 뒤)
# 크롬드라이버 확인용 코드
from selenium import web driver
driver = web driver.Chrome(“[절대경로]”)
위 코드 치고 확인해보면 된다 했는데 내 경우는 안 됐다.
아래 블로그 덕분에 해결했다.
[chromedriver] 개발자를 확인할 수 없기 때문에 'chromedriver'을(를) 열 수 없습니다.
chromedriver 에러
velog.io
작동시킬 프로젝트 폴더 경로에 들어가서
아래 코드를 치고 크롬 드라이버 확인용 코드를 쳐서 잘 됐는지 보면 된다.
xatter -d com.apple.quarantine chromedriver
'Computer > 공부정리' 카테고리의 다른 글
[MySQL]Error Code: 1205. Lock wait timeout exceeded; try restarting transaction (부제: 갑자기 update, delete, insert가 안 된다면..? ) (0) | 2023.10.20 |
---|---|
[Mac] 엑셀 삽입 도형 안 될 때 (0) | 2023.10.17 |
[Mac]맥 폴더 경로 이동하는 또 다른 방법 (0) | 2023.10.16 |
[Mac][Git]맥에 git 설치 (0) | 2023.10.16 |
[Python]selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable → send_keys()로 해결하기 (0) | 2023.10.16 |