Use WatiN for automation upload file on the website -


I need the upload file to website. But there is a problem, I can not choose the automatic file in the code Always the browser shows me the file window to choose what is wrong in my code?

  IE ie = new IE ("https://www.xxxx.com/WFrmlogin.aspx"); FileUploadDialogHandler UploadHandler = New FileUploadDialogHandler (@ "D: \ 065-6405_URGENT.xls"); Ie.WaitForComplete (); Ie.TextField (Find.ById ("txtUser")) TypeText ("Login to") .; Ie.TextField (Find.ById ("txtPassWord")) TypeText ("***") .; Click on ie.Button (Find.ById ("btnok")). Ie.WaitForComplete (); Ie.GoTo ("https://www.orientspareparts.com/inq/WFrmUpOption.aspx"); Ie.WaitForComplete (); Ie.DialogWatcher.Clear (); Ie.AddDialogHandler (uploadHandler); // This code shows file dialog ie IE File uploads ("FilUpload") ClickNoWait (); . Click Ie.Button (Find.ById ("butUpload")) (); Ie.WaitForComplete ();  

I had the same problem. I am using a GMail upload process, so I want to check the actual usage cases. Simply setting text properties on my hidden file input was not an option.

I ended up using SendKeys to type the path of my file, then sent "{ENTER}" to submit the dialog.

Setfindwondo (Browser .hwd); SendKeys.SendWait ("{ENTER}"); Thread.Sleep (500); // Give an unfortunate need, time to communicate to pop up. SendKeys.SendWait (@ "C: \ myfile.jpg {ENTER}")

I do not like this solution, especially not sleep, but it was best that I do Could have been less than 30 minutes.

If someone has a better option then tell me!


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -