mercredi 4 novembre 2020

How to fetch copied content from a clipboard - Selenium headless mode

I have a webpage with a "Copy Link" button, clicking on it copies some data from the text box. Also, these selenium tests will run on Linux machines (headless mode). I used awt Toolkit api and it failed with below stack trace because its running in Linux headless mode. Toolkit doesn't seen to be supported in Linux mode

Test Failed: {}[class: tests.AMUSanityTests, method: test, exception: java.awt.HeadlessException, message: 'No X11 DISPLAY variable was set, but this program performed an operation which requires it.', stack trace: 
sun.awt.HeadlessToolkit.getSystemClipboard(HeadlessToolkit.java:309)

I also tried using selenium sendKeys but this is a void method and hence i cannot fetch the content. There is no place on the webpage for me to paste the content and again copy it for verification.

I need a way to extract the copied content for verification purposes.

Does someone have a solution on how this can be achieved?

Thank you.

Aucun commentaire:

Enregistrer un commentaire