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

How do you capture an element loading after the page load?

484


How can we handle pop-ups in rc?

520


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

499


What is the command that is used in order to display the values of a variable into the output console or log?

633


What are the different Exceptions in selenium?

516






What are the significant changes in upgrades in various selenium versions?

508


How is assert command different from verify command?

517


What is the main disadvantage of implicit wait?

529


Explain Cucumeber Framework?

478


What test can selenium perform?

575


What must one set within side in order to run a test from the beginning to a certain point within the test?

490


where do u maintain all your test cases in manual not in selenium

875


What are the uses of findelement() and findelements()?

470


When do we use findelement() and findelements()?

482


How to perform double click action in selenium webdriver?

479