(Selemium/ python) selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import datetime

path = "C:/Users/ASUS/AppData/Local/Programs/Python/Python39/chromedriver.exe"
driver = webdriver.Chrome(path)
driver.get("https://www.bigkinds.or.kr/v2/news/index.do")

elem = driver.find_element_by_id('total-search-key')
elem.send_keys('((코로나19) OR (코로나) OR (코로나 바이러스) OR (신종 코로나바이러스) OR (COVID-19) OR (코비드19))')

#ERRRRROOOOOOORRRRRRRRRRRRRRRRRRRRRRRRR
elem = driver.find_element_by_xpath('//input[@id="search-begin-date"]')
elem.clear()
elem.send_keys('{year}-{month}-{day}'.format(year=2020, month=1, day=1))
#HEEEEELLLLLLLLPPPPPPPPPPPP

driver.find_element_by_id('방송사').click()

enter = driver.find_element_by_class_name('btn btn-search news-search-btn news-report-search-btn')
enter.click()

I got error in the date searching part, I thought it was because there was already text in that input box, so I cleared it with clear() but it still doesnt work. I don’t know how to solve this problem… please help

under picture is that date box

enter image description here

Answer

  1. You should use explicit waits to have some stability.
  2. clear is not working, not sure why, ideally it should have. so I am doing CTRL+A and then delete.
  3. Launch browser in full screen mode.

Sample code :

driver = webdriver.Chrome(driver_path)
driver.maximize_window()
#driver.implicitly_wait(30)
wait = WebDriverWait(driver, 50)
action = ActionChains(driver)
driver.get("https://www.bigkinds.or.kr/v2/news/index.do")

elem = driver.find_element_by_id('total-search-key')
elem.send_keys('((코로나19) OR (코로나) OR (코로나 바이러스) OR (신종 코로나바이러스) OR (COVID-19) OR (코비드19))')

#ERRRRROOOOOOORRRRRRRRRRRRRRRRRRRRRRRRR
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a[href='#srch-tab1']"))).click()
elem = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='search-begin-date']")))
elem.send_keys(Keys.CONTROL + "a")
elem.send_keys(Keys.DELETE)
elem.send_keys('{year}-{month}-{day}'.format(year=2020, month=1, day=1))

wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "img.ui-datepicker-trigger"))).click()
#HEEEEELLLLLLLLPPPPPPPPPPPP

#driver.find_element_by_id('방송사').click()

enter = driver.find_element_by_css_selector('.btn.btn-search.news-search-btn.news-report-search-btn')
driver.execute_script("arguments[0].scrollIntoView(true);", enter)
enter.click()

Imports :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains