I'm trying to remove readonly tag from an input field by using python and selenium. Can anybody help me here?
Datepicker Image:
HTML:
<input id="startDate" name="START_DATE" type="text" readonly="readonly">
Code I've tried :
driver.execute_script('driver.find_element_by_xpath('" //*[@id = '" 'startDate' "'] "').removeAttribute("readonly")')
CodePudding user response:
To remove the readonly
attribute you need to use removeAttribute() as follows:
element = driver.find_element(By.XPATH, "//input[@class='date hasDatepicker' and @id='startDate']")
driver.execute_script("arguments[0].removeAttribute('readonly')", element);
References
You can find a couple of relevant detailed discussions in: