'WebElement' object is not callable 오류는 WebElement 객체를 함수처럼 호출하려 할 때 발생합니다. 보통 WebElement 객체는 클릭할 수 있는 click() 메서드를 가지고 있기 때문에 이 오류는 잘못된 방식으로 WebElement를 호출하려고 할 때 발생합니다.
예를 들어, WebElement 객체를 click()처럼 사용해야 하는데, WebElement 자체를 함수처럼 호출하려고 할 때 이런 오류가 발생할 수 있습니다.
문제가 발생한 부분을 다시 점검하고, click() 메서드를 제대로 호출하고 있는지 확인해 보세요.
WebDriverWait에서 반환되는 값은 WebElement가 아니기 때문에 바로 click()을 호출하는 방식은 잘못되었습니다.
WebDriverWait는 expected_conditions과 함께 사용해야 합니다.
Before
try:
WebDriverWait(driver, 1).until(driver.find_element(By.CSS_SELECTOR, "button.calendar_date:not(.unselectable)")).click()
WebDriverWait(driver, 1).until(driver.find_element(By.CSS_SELECTOR, "button.btn_time:not(.unselectable)")).click()
except Exception as e:
print("알 수 없는 오류 발생")
print(e)
After
from selenium.webdriver.support import expected_conditions as EC
date_button = WebDriverWait(driver, 1).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, "button.calendar_date:not(.unselectable)"))
)
date_button.click()
# 'btn_time' 버튼이 클릭 가능할 때까지 기다린 후 클릭
time_button = WebDriverWait(driver, 1).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, "button.btn_time:not(.unselectable)"))
)
time_button.click()
이 바부야🥲
리펙토링 한답시고 새로 작성하는 소스에 기존 소스를 옮겨 적다 생긴 오류.. 중단점이 어딘지 몰라서 한참 헤맸다😭