I have a feature in my product which enables the user to select multiple files and upload. I am trying to automate it using selenium. Even though the code works fine in Windows, the file upload is not happening when running the test cases via Jenkins on Ubuntu. Can someone help me to find the error?
Edit: The complete path to the image is framed using the Jenkins home directory, image directory, image name and File.Separator
// Copying the path of the file to the clipboard
StringSelection photo = new StringSelection("complete/path/image1" "complete/path/image2" "complete/path/image3" "complete/path/image4"));
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(photo, null);
Thread.sleep(10000); // Some sleep time to detect the window popup
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
// To Click on the "Open" button to upload files
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
WebElement postImageButton = driver.findElement(Properties.CompleteUploadButton);
CompleteUploadButton.click();