I have a Selenium Java test copying table grid values to clipboard. Then I'm extracting the clipboard content with the following method:
public static String extractTextFromClipboard(){
try {
return (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
}catch (Exception e){
ConsoleLogger.error("Failed to extract text from clipboard " + e.getMessage());
return "";
}
}
and if works just fine when I run the tests locally.
But when I run this test on Jenkins it fails with the following error:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
I saw several questions here dealing with the above error but I still do not understand what can I do to fix my issue?
Are there alternative ways to extract clipboard content so it will work for me?