How to paste a long text to textarea in selenium chrome with python?

1,257 views
Skip to first unread message

א א א

unread,
Oct 11, 2014, 10:07:45 PM10/11/14
to seleniu...@googlegroups.com
Hello,
i have a long long text description (15000 chars) and i want to paste it into a driver text area, but when i do driver.find_element_by_id(elem).send_keys(description)
it take up to 5min in chrome.

please give me a better way.

Phanindra Chowdary Chunduri

unread,
Oct 13, 2014, 2:55:24 AM10/13/14
to seleniu...@googlegroups.com
Try javascript solution.

driver.executeScript("arguments[0].value='"+
longstring+"';", textFieldWebElement);

Andreas Tolfsen

unread,
Oct 13, 2014, 7:28:37 AM10/13/14
to seleniu...@googlegroups.com
As I've mentioned before, this won't actually emulate a user which is
typically what you want to do when you use a tool like Selenium. But
if that's not want, this is fine.

Sowrabh

unread,
Oct 13, 2014, 1:55:13 PM10/13/14
to seleniu...@googlegroups.com
Use the code as below:
Abc = "xyz"*10000. This string variable value is huge. You can make this even huge!
Next step, use pyperclip module in python.
import pyperclip

xyz = pyperclip.copy(Abc)
driver.find_element_by_id("id").send_keys(xyz)

Thanks,
Sowrabha

Sowrabh

unread,
Oct 13, 2014, 2:05:41 PM10/13/14
to seleniu...@googlegroups.com
Or you can also use

driver.find_element_by_id("id").send_keys(pyperclip.paste(xyz))

Regards,
Sowrabha
Reply all
Reply to author
Forward
0 new messages