Reputation: 59
I am getting error (element not interactable) when I am trying to send keys into the input field. When I am trying to only click the input filed I am able to do but when giving text it is showing error I have so many things to solve this but I am getting this error only.
My code:
from selenium import webdriver
Driver=webdriver.Chrome()
Driver=get('https://YouTube.com')
Box=Driver.find_element_by_xpath('//*[@id="search-input"]')
Box.send_keys('music') ```
Upvotes: 2
Views: 3039
Reputation: 9969
To send elements to the search box. First induce a wait for the element to be clickable due to page load.
Box=WebDriverWait(Driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#search")))
Box.send_keys('music')
Import
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
Upvotes: 2
Reputation: 71
Try with that:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
Driver=webdriver.Chrome()
Driver=get('https://YouTube.com')
Box=Driver.find_element_by_xpath('/html/body/ytd-app/div/div/ytd-masthead/div[3]/div[2]/ytd-searchbox/form/div/div[1]/input')
Box.send_keys('music')
Upvotes: 1
Reputation: 203
The searchbar is input(id=search) in div class(search-input). Try this;
from selenium import webdriver
Driver=webdriver.Chrome()
Driver.get('https://YouTube.com')
Box=Driver.find_element_by_id('search-input').find_element_by_id('search')
Box.send_keys('music')
Upvotes: 2