How can I edit/update in a textfield that is disabled ? Python selenium

Viewed 127
<input data-test-id="input-name" type="text" name="name" placeholder="Your name" class="tw-w-full tw-bg-transparent tw-px-2 tw-mr-2 " value="john chrome" disabled="" xpath="1">

<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">

this is my script:

name_ele = driver.find_element_by_xpath("//body/div[@id='root']/div[2]/div[2]/form[1]/div[2]/div[1]/div[1]/div[1]/*[1]").click()
edit_name.send_keys("John")

Im trying to click the button first so that the textfield will enable and i used send_keys but it wont work

1 Answers

Using Javescript executor will solve your problem

name_ele = driver.find_element_by_xpath("//body/div[@id='root']/div[2]/div[2]/form[1]/div[2]/div[1]/div[1]/div[1]/*[1]")

# remove disable attribute from html tag
driver.execute_script('arguments[0].removeAttribute("disabled");', name_ele)
Related