I'm attempting to input text into a textfield using code.
binary = FirefoxBinary("C:\Program Files\Mozilla Firefox\Firefox.exe")
driver = webdriver.Firefox(firefox_binary=binary)
text = 'sending something to the text area'
input_field = driver.find_element_by_css_selector('.trumbowyg-editor')
input_field.clear()
driver.execute_script("arguments[0].value = arguments[1];", input_field, 'sending something to the text area')
However, this approach doesn't seem to work as intended. There are no errors, but nothing happens.
I then tried the following:
binary = FirefoxBinary("C:\Program Files\Mozilla Firefox\Firefox.exe")
driver = webdriver.Firefox(firefox_binary=binary)
text = 'sending something to the text area'
input_field = driver.find_element_by_css_selector('.trumbowyg-editor')
input_field.clear()
driver.send_keys(text)
This method worked, but I prefer sending text with JavaScript code for its faster execution compared to driver.send_keys()
.