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

Explain the difference between confirming and verifying commands?

781


How to get the number of frames on a page?

722


What is Selenese?

787


What kind of keyboard operations can be performed in selenium?

643


What the webdriver supported mobile testing drivers do you know?

662


What is an absolute xpath?

782


What is a keyword driven framework?

727


How can we maximize browser window in selenium?

718


How does one submit a form in selenium?

731


what is the use of x-path?

715


Give selenium ide tool disadvantage?

703


What are different types of locators?

657


Which is the only browser that supports selenium ide to be used?

723


How to run a group of test cases using testng?

745


How is assert command different from verify command?

707