Reputation: 2057
I'm using Selenium WebDriver on Ruby 1.8.7 on an Ubuntu 12.04 desktop. I have a script that dumps the contents (as a string) of a bunch of data files one file at a time into a form. The data files range in size from 44kB to 92kB. I can manually copy and paste the contents into the textarea without error. However, when I use my Ruby script with send_keys on the element the script stalls, fails, and never reports an error.
I know I have the correct element and that send_keys in general works because I've sent 'hello world' to the textarea. I also know I'm grabbing the input file correctly because I can break it up line by line and send entire contents of the file to the textarea one line at a time without error.
The line by line send_keys is doable but fairly slow. I'm assuming that the issue is some form of send_keys limitation on the number of bytes/chars/etc. and that my input files have exceeded that limitation. However, my Google searches have turned up nothing in this regard.
Does anyone know what the limitation here is (send_keys or otherwise)? Ideally if it were a send_keys limitation of 1000 chars I would break the input file up 1000 chars at a time and loop thru until the entire file was sent using send_keys. (And that would certainly be faster than sending it 1 line at a time.) Is there an alternative to send_keys, that I'm unaware of, that can send a string of this size?
Thanks
Upvotes: 0
Views: 1731
Reputation: 895
You could use the clipboard gem and then just use the keyboard shortcut to paste on this element.
Clipboard.copy(data)
$driver.find_element(:id, "elementFoo").send_keys [:control, 'v']
Upvotes: 2