title: How to paste clipboard contents to a file?
body: <p>I can successfully copy the text to the clipboard and new file is also being created at the specified path but data being pasted is wrong.This data is being pasted (File:0x1ff09c8) </p>
  
  <p>I also tried using 'win32/clipboard' but was getting a error 'can't load win32/clipboard'.</p>
  
  <p>As i am using jruby so i installed gem win32-clipboard</p>
  
  <pre><code>$ jruby -S gem install win32-clipboard
  Building native extensions.  This could take a while...
  ERROR:  Error installing win32-clipboard:
          ERROR: Failed to build gem native extension.
  
          c:/jruby-1.7.4/bin/jruby.exe extconf.rb
  NotImplementedError: C extension support is not enabled. Pass -Xcext.enabled=tru
  e to JRuby or set JRUBY_OPTS or modify .jrubyrc to enable.
  
     (root) at c:/jruby-1.7.4/lib/ruby/shared/mkmf.rb:8
    require at org/jruby/RubyKernel.java:1054
     (root) at c:/jruby-1.7.4/lib/ruby/shared/rubygems/custom_require.rb:1
     (root) at extconf.rb:7
  
  
  Gem files will remain installed in c:/jruby-1.7.4/lib/ruby/gems/shared/gems/win3
  2-api-1.4.8 for inspection.
  Results logged to c:/jruby-1.7.4/lib/ruby/gems/shared/gems/win32-api-1.4.8/ext/g
  em_make.out
  </code></pre>
  
  <p>My code</p>
  
  <pre><code>require 'clipboard'
      WAIT.until { driver.find_element(:id, 'btnShowEmbedCode') }.click
        sleep 3
        em = WAIT.until { driver.find_element(:xpath, ".//*[@id='clipboardtext']") }
        em.text
  
     driver.find_element(:xpath, 'html/body/div[31]/div[1]/button').click
     File.open('copy_embed_code.html', 'w') do |f|
     f.truncate(0)
     f &lt;&lt; Clipboard.("#{f}")
     end
  </code></pre>
  
  <p>As win32-clipboard was giving a error so i used clipboard gem.</p>
  
  <p>Above code is working fine with irb but i am not able to do the same in my script.</p>