How to set value of text field all at once with a webdriver? How to set value of text field all at once with a webdriver? selenium selenium

How to set value of text field all at once with a webdriver?


You could directly set the value of the field using execute_script.

Given a page with a textarea:

<html>  <body>    <textarea></textarea>  </body></html>

Inputting the textarea with set took 6-9 seconds (with Firefox/Chrome):

input = 'a' * 4000browser.textarea.set(input)

However, by using execute_script to directly set the value, it only took 0.2 seconds:

input = 'a' * 4000field = browser.textareabrowser.execute_script('arguments[0].value = arguments[1];', field, input)