0

I'm trying to fill in a webform with selenium and python. I'm looping trough all input fields and sending each a "Test" string.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Chrome('C:/Users/kbu/chromedriver.exe')
driver.get('https://skovbakken.halbooking.dk/proc_error.asp')

all_inputs = driver.find_elements_by_xpath("//input[@class='textbox_login']")

for input in all_inputs:
    input.send_keys("Test")
    

Only the first is filled out. Why is that?

This is the error i get:

Traceback (most recent call last):
  File "C:\Users\kbu\Dropbox\Python\squash.py", line 10, in <module>
    input.send_keys("Test")
  File "C:\Users\kbu\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\webelement.py", line 477, in send_keys
    self._execute(Command.SEND_KEYS_TO_ELEMENT,
  File "C:\Users\kbu\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
    return self._parent.execute(command, params)
  File "C:\Users\kbu\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\kbu\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
  (Session info: chrome=84.0.4147.125)

Here is the HTML:

on

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Kresten
  • 810
  • 13
  • 36

1 Answers1

0

The Locator Strategy which you have used:

driver.find_elements_by_xpath("//input[@class='textbox_login']")

identifies exactly 3 elements within the HTML.

The first and last elements are the username and password field respectively.

login

But the second matching element contains the style attribute value as style="DISPLAY: none;:

<input onkeydown="CheckEnterNoIE('logon', event.keyCode)" name="mf_nnpg0fjm" type="password" id="mf_nnpg0fjm" onfocus="if(this.value==multiform.loginvar6.value){this.value='';}" maxlength="50" tabindex="1" class="textbox_login" style="DISPLAY: none;width:120px;">

Hence when your script tries to invoke send_keys() on it you face ElementNotInteractableException.


Reference

You can find a couple of relevant discussion on ElementNotInteractableException in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352