2

I have written a script in python using send_key to type some text in a textarea on this webpage. However, it is really slow to use send_key as my text is really chunky.

from selenium import webdriver

text = "gckugcgaygartty"
link_url ="http://www.bioinformatics.org/sms2/translate.html"

driver = webdriver.Chrome('chromedriver', chrome_options=options)
driver.get(link_url)

driver.find_element_by_tag_name("textarea").clear()
driver.find_element_by_tag_name("textarea").send_keys("gckugcgaygartty")

I then tried to replace the send_keys with execute_script() like following but it didn't work (no errors but nothing changed on the webpage), could anyone give me some advice please?

driver.execute_script("document.getElementById('main_form').getElementsByTagName('textarea')[0].click()")



driver.execute_script("document.getElementById('main_form').getElementsByTagName('textarea')[0].setAttribute('value', 'gckugcgaygartty' )")

1 Answer 1

1

Modification : Changed setAttribute function with value property

Use following Code :

driver.execute_script("document.getElementsByTagName('textarea')[0].value='your_lengthy_data'")

OR

driver.execute_script("document.getElementById('main_form').getElementsByTagName('textarea')[0].value='your_lengthy_data'")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.