Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 부트스트랩 #Bootstrap #웹개발첫걸음 #스파르타코딩클럽
- 항해99솔직후기 #항해99 #부트캠프추천
- 스파르타코딩클럽 #크롤링 #스크래핑
- #내일배움단 #코딩프로젝트 #국비지원 #내일배움카드 #스파르타코딩클럽
- 스파르타코딩클럽 #코딩 #jQuery #Ajax
Archives
- Today
- Total
이모저모
python - selenium_요소와 interaction위한 탐색시 주의사항(?!) 본문
selenium.common.exceptions.ElementNotInteractableException
- 이와 같은 에러가 나는 이유 : presence만 확인해서는 해당 요소와 interaction할 준비가 안 되어 있을 수 있다.
- 대안: visibility로 확인하기
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
import time
import os
import pyperclip
chrome = webdriver.Chrome('./chromedriver')
wait = WebDriverWait(chrome, 10)
short_wait = WebDriverWait(chrome, 3)
chrome.get('https://shopping.naver.com')
# (1) selenium.common.exceptions.ElementNotInteractableException 에러가 나는 코드
# login_btn = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "a#gnb_login_button")))
# (2) 잘 작동되는 코드 : visibility로 확인
login_btn = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "a#gnb_login_button")))
print(login_btn.text)
login_btn.click()
time.sleep(3)
chrome.close()
'coding > python' 카테고리의 다른 글
python - selenium, login (0) | 2022.01.03 |
---|---|
python - selenium, element 찾기, 클릭 (or 엔터키) (0) | 2022.01.03 |
python - selenium, 페이지 로딩 체크하기 (0) | 2022.01.03 |
python - requests, bs4 실습 (0) | 2022.01.01 |
python - 크롤링에서 정규식 사용예시 (0) | 2021.12.31 |
Comments