I'm new to Python and Selenium and am struggling with testing a form for my company website.
I'm trying to enter text into a field. Here is the html:
<input class="form-control" data-val="true" data-val-length="Must be between 2 and 35 characters" data-val-length-max="35" data-val-length-min="2" data-val-requiredif="*First Name is required" data-val-requiredif-dependentproperty="IsMobile" data-val-requiredif-desiredvalue="False" id="FirstName-guide-request-ed9e64ebe3b245a28c9caaabbcd47b95" maxlength="35" name="FirstName" type="text" value="">
Here is the code I use to try to enter the text:
driver = webdriver.Firefox(executable_path = r'C:\Users\jajacobs\Downloads\geckodriver.exe')
driver.get("https://www.graphicproducts.com/guides/5s-system/")
driver.execute_script("window.scrollTo(0, 1000);")
driver.find_element_by_name('FirstName').send_keys('test', Keys.ENTER)
driver.close()
I get the following error:
---------------------------------------------------------------------------
ElementNotInteractableException           Traceback (most recent call last)
<ipython-input-58-6b71ac82d9ce> in <module>
     10 
     11 timeout = 20
---> 12 driver.find_element_by_name('FirstName').send_keys('test', Keys.ENTER)
     13 
     14 driver.close()
~\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py in send_keys(self, *value)
    477         self._execute(Command.SEND_KEYS_TO_ELEMENT,
    478                       {'text': "".join(keys_to_typing(value)),
--> 479                        'value': keys_to_typing(value)})
    480 
    481     # RenderedWebElement Items
~\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py in _execute(self, command, params)
    631             params = {}
    632         params['id'] = self._id
--> 633         return self._parent.execute(command, params)
    634 
    635     def find_element(self, by=By.ID, value=None):
~\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in execute(self, driver_command, params)
    319         response = self.command_executor.execute(driver_command, params)
    320         if response:
--> 321             self.error_handler.check_response(response)
    322             response['value'] = self._unwrap_value(
    323                 response.get('value', None))
~\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py in check_response(self, response)
    240                 alert_text = value['alert'].get('text')
    241             raise exception_class(message, screen, stacktrace, alert_text)
--> 242         raise exception_class(message, screen, stacktrace)
    243 
    244     def _value_or_default(self, obj, key, default):
ElementNotInteractableException: Message: Element <input id="FirstName-guide-request-d277b94a662f45e686bf443012505716" class="form-control" name="FirstName" type="text"> is not reachable by keyboard
There is a search box at the top of the page that I can enter text into just fine with the same code, but modified with a different Name. Here is the html:
<input id="GlobalSearchMobile" name="q" class="srch-term form-control" type="text" autocomplete="off" placeholder="Search by Keyword or SKU">
And here is the code I use to enter text into that search box:
driver = webdriver.Firefox(executable_path = r'C:\Users\jajacobs\Downloads\geckodriver.exe')
driver.get("https://www.graphicproducts.com/guides/5s-system/")
driver.execute_script("window.scrollTo(0, 1000);")
driver.find_element_by_name('q').send_keys('test', Keys.ENTER)
driver.close()
So, basically I cannot figure out why the second set of code works for the search box at the top of the page, while the first set of code does not work for the form in the middle of the page.
I'm happy to supply more html if that is help.
I'm using Python 3.7 in a Jupyter Notebook launch with Anaconda on a Windows 10 machine.
Thank you in advance!