how to upload file other than autoit

Answer Posted / bharat

You can use ROBOT API jars to upload the file. Simply trigger the browse button and when you need to give the location of your file to upload use Robot API to send the location and then again using Robot API press enter.



try {
//Setting clipboard with file location
setClipboardData(fileLocation);
//native key strokes for CTRL, V and ENTER keys
Robot robot = new Robot();

robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
} catch (Exception exp) {
exp.printStackTrace();
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between implicit wait and explicit wait?

560


What does a knot do on the selenium grid?

646


What is the main difference between web-driver and rc?

530


What is testng assert and list out some common assertions supported by testng?

567


Can we test apis or web services using selenium webdriver?

621






What are the steps to run automation using selenium?

604


Why should selenium be selected as a test program?

563


Which all browsers are supported by selenium webdriver?

570


How to handle a dropdown in selenium webdriver? How to select a value from dropdown?

555


What are the programming languages supported by selenium webdiver?

562


How to delete cookies in selenium?

634


Which are the operating systems supported by selenium?

566


How do you upload a file?

611


Explain the difference between close and quit command?

627


What are the annotations available in testng?

562