ElementNotInteractableException: element not interactable error while trying to search for stock on www.finanzen.net using Selenium and Python

Tyler_Durdun :

Im trying to search for stock on www.finanzen.net using selenium but always get

ElementNotInteractableException: element not interactable

from selenium import webdriver

import time

chrome_options = webdriver.ChromeOptions()
prefs = {"profile.default_content_setting_values.notifications" : 2}
chrome_options.add_experimental_option("prefs", prefs)
chrome_options.add_argument("start-maximized")
driver = webdriver.Chrome(options=chrome_options, executable_path=r'F:\chromedriver.exe')

driver.get('https://www.finanzen.net/')
time.sleep(5)
cookie_banner_button = driver.find_element_by_xpath("//button[@onclick='cookieBannerOverlayClick();']")
cookie_banner_button.click()

search_field = driver.find_element_by_xpath("//input[@class='search-input']")


#search_field.click()
search_field.send_keys('bmw')
search_field.submit()
time.sleep(5)
driver.quit()

HTML:

html-code of element

Sameer Arora :

The xpath that you have used are pointing to two elements and first element on which it is pointing is not interactable due to which you are getting the exception.
Have found the correct xpath for the element, please refer to the code below:

from selenium import webdriver

import time

chrome_options = webdriver.ChromeOptions()
prefs = {"profile.default_content_setting_values.notifications" : 2}
chrome_options.add_experimental_option("prefs", prefs)
chrome_options.add_argument("start-maximized")
driver = webdriver.Chrome(options=chrome_options, 
executable_path=r'F:\chromedriver.exe')

driver.get('https://www.finanzen.net/')
time.sleep(5)
cookie_banner_button = driver.find_element_by_xpath("//button[@onclick='cookieBannerOverlayClick();']")
cookie_banner_button.click()

search_field = driver.find_element_by_xpath("//div[@class='shadow']//input[@class='search-input']")
search_field.send_keys('bmw')
search_field.submit()
time.sleep(5)
driver.quit()

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=371487&siteId=1