kazurayam / chromedriverfactory

A Java library that enables you to launch Selenium ChromeDriver using an existing user Profile. That let you to carry cookies over multiple HTTP sessions via user Profile.
0 stars 0 forks source link

Getting Clipbord content from Remote Selenium Chrome Node #44

Open kazurayam opened 1 year ago

kazurayam commented 1 year ago

There was a discussion in the Katalon user forum: https://forum.katalon.com/t/value-from-buffer-copied-link-to-be-assigned-to-groovy-variable/83681/3

The original poster wanted to read the clipboard of a remote browser. I found that JavaScript's Clipboard.readText() is the key to solve the problem. https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/readText

However, I found that I have to understand the security and permissioning around clipboard access.

The following article suggested that we can fully automate granting access to Clipboard by configuring a Chrome's Preference https://sahajamit.medium.com/getting-clipboard-content-from-remote-selenium-chrome-nodes-67a4c4d862bd

profile.content_settings.exceptions.clipboard : {
  "[*.],*": {
    "last_modified": "1576491240619",
    "setting": 1
  }
}

My chromedriverfactory is capable of accepting any custom Preference. So l will add an example of using my Chromedriverfactory so that my selenium java test code can get access to the clipboard text.

kazurayam commented 1 year ago

The following page is a nice test bed

https://codepen.io/RevCred/pen/vxXrww