인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

인프런 커뮤니티 질문&답변

gnslgnsdl3님의 프로필 이미지
gnslgnsdl3

작성한 질문수

[신규 개정판] 이것이 진짜 크롤링이다 - 실전편 (인공지능 수익화)

네이버 메일 자동화 - 01. 새로운 창 제어 하는 법

메일버튼 클릭하고 하단바에 메일버튼을 클릭하려고 하니까 ElementClickInterceptedException 이 발생했어요.

작성

·

59

1

user_id = '****'
user_pw = '****'

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time
import pyperclip


#드라이버 생성
driver = webdriver.Chrome()

driver.implicitly_wait(10)

#페이지 이동
driver.get("https://nid.naver.com/nidlogin.login?mode=form&url=https://www.naver.com/")
time.sleep(1)

#아이디 입력
id = driver.find_element(By.CSS_SELECTOR, '#id')
pyperclip.copy(user_id) #클립보드라는 공간에 user_id를 복사해놓음.
id.send_keys(Keys.CONTROL, 'v') #붙여넣기.
time.sleep(1)
#비밀번호 입력
pw = driver.find_element(By.CSS_SELECTOR, '#pw')
pyperclip.copy(user_pw) #클립보드라는 공간에 user_pw를 복사해놓음.
pw.send_keys(Keys.CONTROL, 'v')
time.sleep(1)

#로그인 버튼 클릭
driver.find_element(By.CSS_SELECTOR, '#log\\.login').click()

# 메일 버튼 클릭
driver.find_element(By.CSS_SELECTOR, '#account > div.MyView-module__my_menu___eF24q > div > div > ul > li:nth-child(1) > a > span.MyView-module__item_text___VTQQM').click()
driver.find_element(By.CSS_SELECTOR, '#account > div.MyView-module__layer_menu_service___NqMyX > div.MyView-module__service_sub___wix9p > div.MyView-module__sub_left___AIWHR > a').click()

#새창으로 전환
driver.switch_to.window(driver.window_handles[1])

# 메일쓰기 버튼 클릭
driver.find_element(By.CSS_SELECTOR, '#root > div > nav > div > div.lnb_header > div.lnb_task > a.item.button_write').click()

# 받는 사람
driver.find_element(By.CSS_SELECTOR, '#recipient_input_element').send_keys('gnslgnsdl@naver.com')

# 제목
driver.find_element(By.CSS_SELECTOR, '#subject_title').send_keys('연습')

#서브페이지로 이동
iframe = driver.find_element(By.CSS_SELECTOR, '#content > div.contents_area > div > div.editor_area > div > div.editor_body > iframe')
driver.switch_to.frame(iframe)

#본문
driver.find_element(By.CSS_SELECTOR, '#log\\.login').send_keys('연습중')

#다시 메인페이지로 이동
driver.switch_to.default_content()

#보내기 버튼 클릭
driver.find_element(By.CSS_SELECTOR, '#content > div.mail_toolbar.type_write > div:nth-child(1) > div > button.button_write_task').click()

에러내용:

예외가 발생했습니다. ElementClickInterceptedException

  •  

Message: element click intercepted: Element <a href="https://mail.naver.com/" target="_blank" class="MyView-module__link_service___Ok8hP">...</a> is not clickable at point (937, 789). Other element would receive the click: <a href="#" role="button" class="SettingView-module__btn_setting___Z_3Uu SettingView-module__type_top___GkN8V" aria-pressed="false">...</a> (Session info: chrome=131.0.6778.205) Stacktrace: GetHandleVerifier [0x00007FF6E6F2FB05+28789] (No symbol) [0x00007FF6E6E986E0] (No symbol) [0x00007FF6E6D3592A] (No symbol) [0x00007FF6E6D90FDE] (No symbol) [0x00007FF6E6D8EA7C] (No symbol) [0x00007FF6E6D8BC46] (No symbol) [0x00007FF6E6D8ABA1] (No symbol) [0x00007FF6E6D7CD60] (No symbol) [0x00007FF6E6DAF43A] (No symbol) [0x00007FF6E6D7C5B6] (No symbol) [0x00007FF6E6DAF650] (No symbol) [0x00007FF6E6DCF654] (No symbol) [0x00007FF6E6DAF1E3] (No symbol) [0x00007FF6E6D7A938] (No symbol) [0x00007FF6E6D7BAA1] GetHandleVerifier [0x00007FF6E726933D+3410093] GetHandleVerifier [0x00007FF6E727E7DD+3497293] GetHandleVerifier [0x00007FF6E7272A73+3448803] GetHandleVerifier [0x00007FF6E6FF7BBB+848171] (No symbol) [0x00007FF6E6EA3C3F] (No symbol) [0x00007FF6E6E9F6E4] (No symbol) [0x00007FF6E6E9F87D] (No symbol) [0x00007FF6E6E8ED49] BaseThreadInitThunk [0x00007FF906E3259D+29] RtlUserThreadStart [0x00007FF90852AF38+40]

File "C:\Users\gnslg\OneDrive\바탕 화면\PYTHON_CRAWLLING\셀레니움실전테크닉\06네이버메일자동화.py", line 36, in <module> driver.find_element(By.CSS_SELECTOR, '#account > div.MyView-module__layer_menu_service___NqMyX > div.MyView-module__service_sub___wix9p > div.MyView-module__sub_left___AIWHR > a').click() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <a href="https://mail.naver.com/" target="_blank" class="MyView-module__link_service___Ok8hP">...</a> is not clickable at point (937, 789). Other element would receive the click: <a href="#" role="button" class="SettingView-module__btn_setting___Z_3Uu SettingView-module__type_top___GkN8V" aria-pressed="false">...</a> (Session info: chrome=131.0.6778.205) Stacktrace: GetHandleVerifier [0x00007FF6E6F2FB05+28789] (No symbol) [0x00007FF6E6E986E0] (No symbol) [0x00007FF6E6D3592A] (No symbol) [0x00007FF6E6D90FDE] (No symbol) [0x00007FF6E6D8EA7C] (No symbol) [0x00007FF6E6D8BC46] (No symbol) [0x00007FF6E6D8ABA1] (No symbol) [0x00007FF6E6D7CD60] (No symbol) [0x00007FF6E6DAF43A] (No symbol) [0x00007FF6E6D7C5B6] (No symbol) [0x00007FF6E6DAF650] (No symbol) [0x00007FF6E6DCF654] (No symbol) [0x00007FF6E6DAF1E3] (No symbol) [0x00007FF6E6D7A938] (No symbol) [0x00007FF6E6D7BAA1] GetHandleVerifier [0x00007FF6E726933D+3410093] GetHandleVerifier [0x00007FF6E727E7DD+3497293] GetHandleVerifier [0x00007FF6E7272A73+3448803] GetHandleVerifier [0x00007FF6E6FF7BBB+848171] (No symbol) [0x00007FF6E6EA3C3F] (No symbol) [0x00007FF6E6E9F6E4] (No symbol) [0x00007FF6E6E9F87D] (No symbol) [0x00007FF6E6E8ED49] BaseThreadInitThunk [0x00007FF906E3259D+29] RtlUserThreadStart [0x00007FF90852AF38+40]

 

메일버튼 클릭하고 하단바에 메일버튼을 클릭하려고 하니까 ElementClickInterceptedException 이 발생했어요.

driver.find_element(By.CSS_SELECTOR, '#account > div.MyView-module__layer_menu_service___NqMyX > div.MyView-module__service_sub___wix9p > div.MyView-module__sub_left___AIWHR > a').click()

여기서 발생하는거 같은데 이유가 뭘까요..?

답변 1

0

스타트코딩님의 프로필 이미지
스타트코딩
지식공유자

답변을 드렸었지만 한번더 알려 드려요!

 

element = driver.find_element(By.CSS_SELECTOR, '.submit-button')
driver.execute_script("arguments[0].click();", element)

이런식으로 element 를 찾아서 강제로 클릭하게 만들 수 있습니다

gnslgnsdl3님의 프로필 이미지
gnslgnsdl3

작성한 질문수

질문하기