Reputation: 1624
i am trying to automate here and now i want to fill some text in a form which appears after clicking on a button(yellow highlighted one). How to do that??
Just to be clear, i want to fill the text-field and click the filter . But i am not able to access it . How to do that after i click the funnel button??
I tried :
i tried to alter the window handle , but it did not work.
Directly i accessed the element by css selector, but an error is coming as 'selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable'
Here is the code :
#clicked the button and the form appeared
ddf=driver.find_element_by_css_selector('span.k-icon.k-filter').click()
print('Clicked..') #Its working...
#Trying to fill the text in the form and filter it
#Both the below lines are not working
driver.find_element_by_css_selector('input.k-textbox').send_keys('ddf')
driver.find_element_by_css_selector('button.k-button') .click()
print('filtered..')
UPDATE 1 : I got 3 answers, still the prolem persists. **i am able to click the funnel button and filter button, but cant fill the text field in the form **
Upvotes: 0
Views: 2324
Reputation: 83
ElementNotInteractableException
occurs when an element is found, but you can't be interacted with it because for example element is hidden by another element or is not displayed for some reason and is not clickable anymore.
Does the field for filling filter meet the requirements? Also you didn't say on which exactly step it failed. Anyway maybe using Wait until an element is visible / clickable could help in this case. As example:
from selenium.webdriver.support import expected_conditions as EC
element = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS, "button.k-button"))
)
Upvotes: 2
Reputation: 7563
You can try using ActionChains
:
driver.find_element_by_css_selector('span.k-icon.k-filter').click()
driver.implicitly_wait(2)
input_element = driver.find_element_by_css_selector('input.k-textbox')
filter_element = driver.find_element_by_css_selector('button.k-button')
action = ActionChains(driver)
#Update here
action.move_to_element(input_element).click(input_element).send_keys('ddf').perform()
action.move_to_element(filter_element).click(filter_element).perform()
Following import:
from selenium.webdriver import ActionChains
#UPDATE
Or other approach with .execute_script
:
driver.execute_script('document.querySelector("input.k-textbox").setAttribute("value", "ddf");')
element = driver.find_element_by_css_selector('input.k-textbox')
driver.execute_script("arguments[0].value = 'ddf';", element)
driver.execute_script("document.querySelector('input.k-textbox').innerHTML = 'ddf';");
Upvotes: 1
Reputation: 33384
To handle dynamic element Induce WebDriverWait
and element_to_be_clickable
()
ddf=WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"span.k-icon.k-filter")))
ddf.click()
You need to import following libraries.
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
If you are getting same error try use Javascripts Executor
to click.
ddf=WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"span.k-icon.k-filter")))
driver.execute_script("arguments[0].click();",ddf)
Upvotes: 1