Recently, I had the challenge of writing some automation for a work flow which included uploading a file because uploading a file works on windows component.
selenium is unable to access windows components and it will be handled through AutoIT.
Once you are able to click on browse button and a dialog box is open to choose the file then you just run a AutoIT script which will help to select the file from your local or remote drive and control will come to your web page to proceed with selenium.
Step to choose a file from your local or remote drive
Click on browse button on your web page and go to second step.If you are unable to click on browse button then visit below page.
How to click on browse button
write a AutoIT script to choose a file from your local or remote drive.
WinActivate("Choose file"); Local $file = "c:\yourpath\howtoupload.doc" ControlSetText("Choose file", "", "Edit1", $file ) ControlClick("Choose file", "", "Button2")
Complie AutoIT script and make exe of that script.
Right click on that saved script file and click on "Compile script" from context menu. This will make an exe file of that script.
Call that exe in selenium.
Download AutoIT script
Process proc = Runtime.getRuntime().exec("C:\\Documents and Settings\\nirkumar\\Desktop\\Browse.exe");
Download exe file of AutoIT script
If you want to test this script then just download the script exe file and click on browse button on web page and run this exe file. Just make sure you have your file in correct path by changing this line of script in the second step
Local $file = "c:\yourpath\howtoupload.doc"
in above line of script change your file path then make exe of your script then click on browse button on your web page then run this exe . I am sure this would work.
If it still is nor working then change the script like
WinActivate("File Upload"); Local $file = "c:\yourpath\howtoupload.doc" ControlSetText("File Upload", "", "Edit1", $file ) ControlClick("File Upload", "", "Button2")