1. First install autoit from www.autoitscript.com/site/autoit/downloads
2. Create an autoit file with below code say abc.au3 file and create exe file for this file (abc.au3 file) using autoit say "attachFile.exe" and save it in "C:\\ABCAutomation"
Auto IT code:-
WinWaitActive("File Upload")
Send("C:\Users\neeraj\Desktop\sample.doc")
Sleep(1000)
ControlClick("File Upload", "", "Button1")
Save this code with extension.au3 and after saving Compile the Script to convert it into .exe file which AutoIt can run
Selenium code to Handle Upload button using AutoIT
driver.findElement(By.xpath("/ /*[starts-with(@class,'a1')]") ).click(); // To click browse button to open Dialog box
String[] commands = new String[2];
commands = new String[]{"C:\\Users\\neeraj\\ Desktop\\autoitfile_upload. exe"}; //location of the autoit executable
Runtime.getRuntime().exec( commands); // To run exe file and handle dialog box
Thread.sleep(7000);
OR Directly write: Runtime.getRuntime().exec("C:\\Documents and Settings\\Neeraj.Bakhtani\\Desktop\\Browse.exe");
used the above code but not able to proceed beyond open window to upload image
ReplyDeleteplease help
Check the name of Upload Pop up Menu, in my Case it was File Upload.
ReplyDeleteOr share some details and screenshot to look into the issue.
Thanks
Clicking on Upload button on the browser, it opens up a windows explorer window ("Open") and trying to select a file, but not getting any file output back, used as
ReplyDeleteWinWaitActive("Open")
Send("C:\Users\Public\Pictures\Sample Pictures\Desert.jpg")
Sleep(1000)
ControlClick("Open", "", "Open")
Hi Neeraj Ji,
ReplyDeleteThanks a lot for this wonderful site.
Do you have any facebook/Google+ accounts.. where you can posts your content and status(when new content is published)...?
Thank You..
~Chaitanya
Hi Chaitanya,
ReplyDeleteYes You can join the blog or you can follow by email, or Add google+.
You will receive all latest posts updates
Hi Neeraj ! Can You Plz tell me how to import photo from Facebook in selenium webdriver.i am using java.
ReplyDeletethanks a lot..
ReplyDeletehi neeraj .. im trying to run autoit for uploading the file using ur mechanism.. what happens is i click the browse button named "open". then run the autoit exe but still nothing happens.. it just opens the dialog and nothing happens after that.. need some help on this
ReplyDeleteHi Neeraj,
ReplyDeleteI tried the same code for uploading file,it is working fine till capturing the path location after that it stops please let me know how can fix this issue.
Thanks,
Pavitra
Hi Neeraj,
ReplyDeleteI used the same code which you have posted for file upload,it works fine till capturing path.After capturing the path its not selecting the given file,please let me know how to resolve this issue at the earliest.
Thanks,
Pavitra
how to make this code generic like I should be able to pass the path of the file that has to be uploaded from selenium java code to autoit code as a parameter.
ReplyDelete