I am trying to send keys to the below field using below python selenium code
<input type="text" name="date_startDateSql" readonly="" class="EditableRequiredField" onfocus="setday(this)">
Selenium Python Code :
element=driver.find_element_by_name('date_startDateSql')
element.send_keys('12/10/2017')
I am not getting any error or exception but not able to send keys into this element.I am new to python selenium and would appreciate if someone could advise how to send keys to the fields that are readonly.
Remove the readonly attribute of your input before sending keys :
driver.execute_script('document.getElementsByName("date_startDateSql")[0].removeAttribute("readonly")')
This worked perfectly!
If there aren't multiple elements with the same ID, you can use:
driver.execute_script('document.getElementById("ELEMENT ID").removeAttribute("readonly")')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With