I have an input field on a webpage that I want to access and set the value. To do so, I have the following:
element = browser.find_element_by_id("input")
driver.execute_script('arguments[0].scrollIntoView()', element)
browser.wait_until_element_is_visible(element)
element.clear()
driver.execute_script(f'arguments[0].value = "{input_value}"', element)
The above works but sometimes when setting the input field's value it doesn't actually set it on the webpage, so the input field will be empty. But when I output: print(element.get_attribute('value'))
, it is returning exactly what I wanted the input field to have (so following the example, input_value
).
I want to change the input field on the UI by setting the input's value attribute and prefer not to use sendKeys()
as these input strings are very long. So does anyone know how to make the input field value show up on the webpage?