Reputation: 113
I am trying to enter text into an input field using python and selenium but I am getting an error that tells me -> Message: element not interactable
Here is the code that is failing:
webdriver.ActionChains(self.driver).send_keys(Keys.TAB).perform()
webdriver.ActionChains(self.driver).send_keys(Keys.TAB).perform()
time.sleep(15)
WebDriverWait(self.driver, 15).until(EC.presence_of_element_located((By.XPATH, "//span[contains(@class, 'input-container')]"))).send_keys("test")
The element has a class name of input-container and I am trying to navigate to it with the tabs and then put "test" into it. I also tried clicking on it before this and got the same error. Here is the code for that:
WebDriverWait( self.driver, 30).until(EC.element_to_be_clickable((By.XPATH, "//span[contains(@class,'input-container')]"))).click()
time.sleep(15)
WebDriverWait(self.driver, 15).until(EC.presence_of_element_located((By.XPATH, "//span[contains(@class, 'input-container')]"))).send_keys("test")
I added the sleep to see if I was actually clicked onto the text field and I was but am still receiving this error. The full stack trace is here:
Traceback (most recent call last):
File "/Users/user1/Desktop/btm.py", line 124, in <module>
b.begin()
File "/Users/user1/Desktop/btm.py", line 80, in begin
WebDriverWait(self.driver, 15).until(EC.presence_of_element_located((By.XPATH,
"//span[contains(@class, 'input-container')]"))).send_keys("test")
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-
packages/selenium/webdriver/remote/webelement.py", line 233, in send_keys
self._execute(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-
packages/selenium/webdriver/remote/webelement.py", line 410, in _execute
return self._parent.execute(command, params)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-
packages/selenium/webdriver/remote/webdriver.py", line 444, in execute
self.error_handler.check_response(response)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-
packages/selenium/webdriver/remote/errorhandler.py", line 249, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not
interactable
(Session info: chrome=108.0.5359.98)
The input element looks like this
<span class="input-container span-to-div"><input aria-label="Blank 1 of 1" autocapitalize="off" autocomplete="new-password" autocorrect="off" class="fitb-input " id="fitbTesting_eebce337-d24b-4253-82cd-878f339bf49b" maxlength="50" name="fitbTesting_4bfacf11-846f-48c8-9821-f276b3ef43b8" spellcheck="false" value=""><span aria-label="Empty Blank 1 of 1" class="_visuallyHidden"></span></span>
And this is what my screen looks like within the 15-second time frame before I try to send "test" to the input
If I left out any necessary information please let me know and I'll be happy to add it to my post!
Upvotes: 0
Views: 544
Reputation: 113
Figured out the solution. I was attempting to pass input to a span and not the actual input tag itself
The updated version of my code that works is here:
WebDriverWait(self.driver, 15).until(EC.presence_of_element_located((By.XPATH, "//input[contains(@aria-label, 'Blank "+ str(x) + " of " + aria_label[len(aria_label) - 1] + "')]"))).send_keys("test")
Where x and aria-label are integers representing the current input (x) and the total amount of inputs (aria_label)
Upvotes: 1