Autoit is a freeware windows testing tool. Autoit allows you accessing windows components similar to QTP. Basically once you have identified the id of the component on the screen you can use it by either clicking on it, typing in something. Using Autoit we can identify the internet explorer “Choose file” or Firefox
“File Upload” windows and enter the correct value to the input
field after which you will press the open button.
Step to click on browse button.
Download the AutoIT and intall it.
write a AutoIT script to click on browse button and save it.
#include <IE.au3> ; Internet Explorer is partly integrated in shell.application $oShell = ObjCreate("shell.application") ; Get the Windows Shell Object $oShellWindows=$oShell.windows ; Get the collection of open shell Windows $MyIExplorer="" for $Window in $oShellWindows ; Count all existing shell windows ; Note: Internet Explorer appends a slash to the URL in it's window name if StringInStr($Window.LocationURL,"http://") then $MyIExplorer=$Window exitloop endif next $oForm = _IEGetObjByName ($MyIExplorer, "UploadedFile") _IEAction($oForm, "click")
Compile AutoIT script and make exe file 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.
This will click on browse button and open choose file or upload file dialog box.
Process proc = Runtime.getRuntime().exec("C:\\Documents and Settings\\nirkumar\\Desktop\\Browse.exe");
Download AutoIT script
Download exe of that script
If you want to test this script works then download the exe and open the page which has browse button and run(double click on this exe) this exe file. i am sure this
will click on your browse button and open a dialog box. If it does not then definitely your browse button has some other name than "UploadedFile" then in the step 2 change the button name and make exe of that script and run it.
NOTE: This will work in Internet explorer.