I am trying to access the file upload element from a webpage and handle it to upload a file and click on submit for processing. Please tell me how to handle the file upload dialog boxes? Also when using the code, it got struck-ed in the find element module itself. What can i do for that?
Asked
Active
Viewed 1,027 times
-1
-
3You can have a look at this one: http://stackoverflow.com/questions/11256732/how-to-handle-windows-file-upload-using-selenium-webdriver Hope this helps – Murali May 28 '16 at 08:55
-
2There are n number of possible solutions over the internet. Have you tried anything ? if your question or issue is different than others then post your UI/HTML. – Chandrashekhar Swami May 28 '16 at 09:00
1 Answers
0
driver.findElement(By.id("SWFUpload_0")).click();
Robot r = new Robot();
r.keyPress(KeyEvent.VK_C); // C
r.keyRelease(KeyEvent.VK_C);
r.keyPress(KeyEvent.VK_COLON); // : (colon)
r.keyRelease(KeyEvent.VK_COLON);
r.keyPress(KeyEvent.VK_SLASH); // / (slash)
r.keyRelease(KeyEvent.VK_SLASH);
// etc. for the whole file path
r.keyPress(KeyEvent.VK_ENTER); // confirm by pressing Enter in the end
r.keyRelease(KeyEvent.VK_ENTER);

ADHITHYA SRINIVASAN
- 105
- 11
-
1The most weird option :) why not just to sent the path strint to `...` element with `driver.findElement(By.id("SWFUpload_0")).sendKeys(pathToFile);`? – Andersson May 28 '16 at 12:02