Question

I am trying to set value in textbox after enabling it forcefully through javascript executor in my Selenium (Ruby binding) automation script.

input_fieldcar1 = browser.find_element(:xpath, "/html/body/div[5]/div/div[3]/div[2]/div[2]/div/div/div/div/div[2]/div[2]/div/div/div/div[2]/div/div/div[5]/div/div[2]/div[2]/div/div/div/div[4]/div/div/div[3]/div/div/input")
browser.execute_script('arguments[0].removeAttribute("disabled");', input_fieldcar1)

I tried

input_fieldcar1.send_keys"7"

browser.execute_script('arguments[0].setAttribute("innerHTML","1");', input_field1)

but none of these work!

Also the script ends peacefully without throwing an error etc.

What could be missing / wrong?

Was it helpful?

Solution

Since it's a textbox, so maybe give value attribute a go?

browser.execute_script('arguments[0].value = "1";', input_field1)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top