File upload functionality is not working with Robot class in Linux OS

44 views
Skip to first unread message

shruthi v v

unread,
Jul 27, 2016, 3:55:40 AM7/27/16
to seleniu...@googlegroups.com
Hello Group,

 I am trying to automate file upload control for uploading image files in Linux operating system but file upload is not working. Here Test will execute successfully but when I open my web page there no files are getting attached.

I can not visualize the execution as this test is running on Linux machine from Jenkins. Same piece of code is working fine on windows machine. Please help 

Here is my code
 //To upload multiple files at a time
                String img="/var/lib/jenkins/jobs/ShruthiTest/workspace/NewTestNg/ImageUploadsFile/images (1).jpg";
                StringSelection sel = new StringSelection(img);

// Copy to clipboard
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(sel,null);
System.out.println("selection clipboard" +sel);

// This will click on Browse button
driver.findElement(By.id("imageFileLabel")).click();
System.out.println("Image upload window is now opened");
Thread.sleep(1000);

// Create object of Robot class
Robot robot = new Robot();
Thread.sleep(1000);
                System.out.println("Robot class initiated");

// Press Enter
robot.keyPress(KeyEvent.VK_ENTER);
Thread.sleep(1000);
                System.out.println("Robot hit enter");

// Release Enter
robot.keyRelease(KeyEvent.VK_ENTER);
Thread.sleep(1000);
                System.out.println("Robot Release enter");

       // Press CTRL+V
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
Thread.sleep(1000);
                System.out.println("Robot copy");

// Release CTRL+V
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_V);
Thread.sleep(1000);
System.out.println("Pasted file");

//Press Enter
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);

       












Shruthi

shruthi v v

unread,
Aug 2, 2016, 11:56:04 AM8/2/16
to seleniu...@googlegroups.com

please suggest what is wrong in my test case?

shruthi

Reply all
Reply to author
Forward
0 new messages