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
What is the difference between implicit wait and explicit wait?
What does a knot do on the selenium grid?
What is the main difference between web-driver and rc?
What is testng assert and list out some common assertions supported by testng?
Can we test apis or web services using selenium webdriver?
What are the steps to run automation using selenium?
Why should selenium be selected as a test program?
Which all browsers are supported by selenium webdriver?
How to handle a dropdown in selenium webdriver? How to select a value from dropdown?
What are the programming languages supported by selenium webdiver?
How to delete cookies in selenium?
Which are the operating systems supported by selenium?
How do you upload a file?
Explain the difference between close and quit command?
What are the annotations available in testng?