Use WatiN for automation upload file on the website
Posted
by
MrDuDuDu
on Stack Overflow
See other posts from Stack Overflow
or by MrDuDuDu
Published on 2010-06-15T07:52:34Z
Indexed on
2010/12/24
1:54 UTC
Read the original article
Hit count: 623
I need upload file on the website. But Have a problem, i can't choose file automatic in code. Always browser show me choose file window. What 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");
ie.TextField(Find.ById("txtPassWord")).TypeText("***");
ie.Button(Find.ById("btnok")).Click();
ie.WaitForComplete();
ie.GoTo("https://www.orientspareparts.com/inq/WFrmUpOption.aspx");
ie.WaitForComplete();
ie.DialogWatcher.Clear();
ie.AddDialogHandler(uploadHandler);
// This code show choose file dialog
ie.FileUpload(Find.ById("FilUpload")).ClickNoWait();
ie.Button(Find.ById("butUpload")).Click();
ie.WaitForComplete();
© Stack Overflow or respective owner