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 assertion in selenium and what are the types of assertion?

675


What is heightened privileges browsers?

765


List the different types of locaters in selenium.

693


What are the challenges in handling ajax call in selenium webdriver?

733


How can we select elements by their attribute value using css selector?

878


selenium can handle pop-up windows based on selenium is a test tool?

881


What are some limitations of selenium?

682


List out the technical challenges with selenium?

713


Tell me what kind of mouse actions can be performed in selenium?

703


What are testing types supported by selenium?

698


Mention what is desired capability? How is it useful in terms of selenium?

690


Can I navigate back and forth in a browser in selenium webdriver?

786


What are the different methods to refresh a web page in webdriver?

688


What are the features of selenium ide ?

763


How to handle hidden elements in selenium webdriver?

690