Reputation: 605
I am using selenium webdriver and ruby. Long story short i am working on a web application which on click of a button copies all the data in the text field to the clipboard. I want to access that data and compare if a string is present.
I have installed clipboard and win32/clipboard gems.Here is my code
include Win32
abc = Clipboard.data
em = " ooyalaPlayer = OO.Player.create('playerContainer',"
puts 'true' if abc.include? em
Here is the error stack
$ jruby tests/embed_add_remove_playlist.rb -b firefox -a staging
ui-test-support will place screenshots and additional logs under:
results_dir=E:/testing/behavioral_tests/themebuilder/results
c:/jruby-1.7.4/lib/ruby/shared/rubygems/custom_require.rb:36: Use RbConfig inste
ad of obsolete and deprecated Config.
LoadError: no such file to load -- win32-clipboard
require at org/jruby/RubyKernel.java:1054
require at c:/jruby-1.7.4/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at E:/testing/behavioral_tests/themebuilder/lib/embed_helper.rb:8
require at org/jruby/RubyKernel.java:1054
require at c:/jruby-1.7.4/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at tests/embed_add_remove_playlist.rb:8
Upvotes: 5
Views: 3601
Reputation: 31246
If you have access to a linux or osx system, you can do the following:
Write text to a file like this:
IO.write('/tmp/msg.txt', 'hi')
Read it back like this:
IO.read('/tmp/msg.txt')
Frequently, I want to read a file into my clipboard ***
Clipboard.copy IO.read('/tmp/msg.txt')
And other times, I want to write what's in my clipboard to a file ***
IO.write('/tmp/msg.txt', Clipboard.paste)
*** Assumes you have the clipboard gem installed
See: https://rubygems.org/gems/clipboard
Upvotes: 2
Reputation: 14076
First install 'win32-clipboard':
gem install win32/clipboard
Then do following :
require 'win32-clipboard'
include Win32
abc = Clipboard.data
puts abc
Upvotes: 2