반전공자

[크롤링] 셀레니움 버튼 못찾음 에러 해결 본문

데이터분석

[크롤링] 셀레니움 버튼 못찾음 에러 해결

하연01 2023. 3. 22. 16:52

동적 크롤링 때 아래같은 에러가 참 많이 보인다.

 

Message: element click intercepted: Element <a href="#" role="button" data-nclick="N=a:rev.page,r:...">12</a> is not clickable at point (443, 15). Other element would receive the click: <div class="floatingTab_info_area__Cupbq">...</div>
Message: stale element reference: element is not attached to the page document

 

 

여러번 에러에 뚜드러 맞으면서 깨달은 방법

 

 

해결책

 

방법 I. send_keys로 키 이벤트 보내기

element5 = dr.find_element_by_css_selector('#section_review > div.pagination_pagination__JW7zT > a:nth-child(3)').send_keys(Keys.ENTER)

 

 

 

방법 II. ActionChains 사용 

from selenium.webdriver import ActionChains
act = ActionChains(dr)

element = dr.find_element_by_css_selector('#section_review > div.pagination_pagination__JW7zT > a:nth-child(10)')
act.click(element3).perform()

 

 

방법 III. 엘리먼트 찾고 바로 클릭

dr.find_element_by_css_selector('#section_review > div.pagination_pagination__JW7zT > a:nth-child(3)').click()