0

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();
  • Is there any error reported? – Alexey R. Jan 15 '18 at 14:56
  • on seeing the logs and stacktrace, i can see that multiple file selection is not happening in ubuntu. – Jayan Kuttagupthan Jan 15 '18 at 15:00
  • Have you looked at this question? https://stackoverflow.com/questions/14242719/copying-to-global-clipboard-does-not-work-with-java-in-ubuntu or this wiki entry? https://wiki.ubuntu.com/ClipboardPersistence – Rescis Jan 15 '18 at 17:18
  • Selenium supports muti-upload directly by calling `sendKeys` on the `` element with the paths separated by a line-break character. – Florent B. Jan 15 '18 at 19:11

0 Answers0