콘솔워크

[selenium] 요소가 존재하지만 클릭 할 수 없는 오류 'Element is not clickable at point' 본문

프로그래밍/python

[selenium] 요소가 존재하지만 클릭 할 수 없는 오류 'Element is not clickable at point'

이휘재123 2022. 6. 17. 17:21
반응형

selenium으로 작업을 하다보면 간혹 요소가 존재하지만 클릭 할 수 없는 오류가 발생한다.

보통 해당 요소로 스크롤을 내려 화면에 보이게하면 해결이 되는 간단한 문제이다.

 

이런 경우에는 ActionChains.move_to_element() 메소드를 활용하면 간단하게 해결 할 수 있다.

 

코드 사용예시

from selenium.webdriver.common.action_chains import ActionChains

your_el = driver.find_element(By.CSS_SELECTOR, '#your_el')
print(have_next)
                
# 해당 요소가 화면에 존재하지 않으면 클릭할 수 없으므로 요소가 보일때까지 스크롤하는 액션
actions = ActionChains(driver).move_to_element(your_el)
actions.perform()
your_el.click()

 

반응형