Can't interact with elements in Selenium on Python

Viewed 53

I've been trying to search this website 'https://mol.org/regions/?regiontype=countries'. But I keep getting the ElementNotInteractableException. I've tried a lot of methods online but nothing seems to work. Here is my latest approach:

search_query = 'Egypt'
search_bar_XPath = '//div[@class="region-search"]/div/input[1]'

with webdriver as driver:
    wait = WebDriverWait(driver, 10)
    driver.get(url)
    wait.until(presence_of_element_located((By.CLASS_NAME, 'region-search')))
    search_bar = driver.find_element_by_xpath(search_bar_XPath)
    ActionChains(driver).move_to_element(search_bar).click().perform()
    wait.until(EC.element_to_be_clickable((By.XPATH, search_bar_XPath))).send_keys(search_query + Keys.RETURN)
    
    driver.close()

I can't figure out why the search bar is present but yet not interactable nor accessible.

1 Answers

Your issue looks like with browser screen size :

try this :

driver.maximize_window()

I tried the below code :

driver.maximize_window()
driver.implicitly_wait(30)
driver.get("https://mol.org/regions/?regiontype=countries")
driver.maximize_window()
wait = WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[placeholder='Filter Political boundaries']"))).send_keys('Egypt')
Related