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 do we mean selenium selenium 1 and 2?

498


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

553


How can we check if an element is enabled for interaction on a web page?

428


What is the selenium's recording language?

535


How do you handle alert popup?

522






What is a node in selenium grid?

548


What differs the configuration of Selenium Selenium 2.0 1.0?

492


Explain Cucumeber Framework?

462


What is pom (page object model)? What are its advantages?

464


How to switch to a new window (new tab) which opens up after you click on a link?

507


Explain how can you find broken links in a page using selenium webdriver?

476


What are the benefits of automation testing?

554


What does a knot do on the selenium grid?

569


How testing is better than junit?

502


How to submit a form using selenium webdriver?

518