1

The ruby code is running in Linux machine and the test browser is running in the windows(node) machine.

And in the webpage, I am selecting a content and doing ctrl+c(keyboard action)

So, the content being copied to windows machines clipboard.

How do I access the windows clipboard content using ruby?

  driver.action.key_down(:control)
    .send_keys('c')
    .key_up(:control)
    .perform

File.open(windows_text_file_path, 'w+') { |file| file.write(Clipboard.paste) }

I have used the Clipboard method, but it is returning the linux machines clipboard contents.

Note: I have tried pasting the clipboard content into windows/linux shared folder, to check whether it is accessible, but the same error.

Vignesh Paramasivam
  • 2,360
  • 5
  • 26
  • 57
  • Is there a particular reason that you use ctrl-C instead of using WebElement.getText()? – Breaks Software Feb 21 '16 at 15:55
  • yes. I am using ctrl+a to select all contents from web page(and it is pdf element which is in embed tag). – Vignesh Paramasivam Feb 22 '16 at 09:23
  • I see, you need to verify content of an embedded PDF. Is this solution what you were looking for? [link](http://stackoverflow.com/questions/3563147/can-selenium-verify-text-inside-a-pdf-loaded-by-the-browser) – Breaks Software Feb 23 '16 at 19:55
  • Yes, i have done a very similar thing(i mentioned in my question too, that i'm copying the content), except that i'm unable to get the clipboard content(since the code base is in linux, and node is in windows), so i have opened a notepad in browser, pasted the content(ctrl+v), and got the html text of the notepad for verification. And there are few glitches, but handled it based on our needs. – Vignesh Paramasivam Feb 25 '16 at 09:42
  • Seems like a reasonable workaround! – Breaks Software Feb 25 '16 at 13:35

0 Answers0