I am trying to change the value of an input tag element.
Here is the tag: <input type="hidden" id="hiRequestAccessType" data-bind="value: requestAccessTypeStr" value="2">
I want to change value to "2,1".
Based on discussion at Set value of input instead of sendKeys() - selenium webdriver nodejs, I tried using execute_script, but value remains unchanged.
I tried this:
passwordcheck_input_element = driver.find_element_by_xpath('//*[@id="hiRequestAccessType"]') . ###THIS DOESNT THROW ERRORS
new_value = "2,1"
driver.execute_script("arguments[0].value = arguments[1].toString()", passwordcheck_input_element, new_value)
# driver.execute_script("arguments[0].value = '" + new_value + "'", passwordcheck_input_element) . ###TRIED THIS IN LIEU OF ABOVE
For either alternative, code runs but value remains unchanged from visual inspection. I also tried the above two alternatives using 'setAttribute' instead of directly, same (no change) result.
Note that the webpage is a form where clicking on a check box changes value to "2,1" as desired. (But if I try finding the check box element, I get the message it is not clickable, hence this route).
Now, what's weird is I know it's doing something right behind the scenes because I tried querying value attribute before and after my execute_script call and it prints out the new value correctly for latter. However, as I said, the UI doesnt show this change; further, when I move on and hit the submit buttom further down, it's the old value that gets used because I am not getting the page that should load if the new value were used.