How do I use the FileUploadDialogHandler in watin to access the file upload dialog

陌路散爱 提交于 2019-12-07 08:56:51

问题


I'm using IE8 with watin and am trying to test uploading a file via my webpage. I can't simply set the upload file using the set method like

ie.FileUpload(Find.ById("someId")).Set("C:/Desktop/image.jpg");

because the upload textarea is not writeable in IE8, so I have to use the FileUploadDialogHandler but I can't find any examples of how to do this.

I have found and used examples of the ConfirmDialogHandler successfully, but I can't seem to figure out how to use the FileUploadDialogHandler.

Any examples would be greatly appreciated.


回答1:


Your code looks OK. You don't have to use FileUploadDialogHandler. It is used internally when you call Set method.




回答2:


Try this code

FileUploadDialogHandler fileupload = new FileUploadDialogHandler("filename.xls");
using (new UseDialogOnce(ie.DialogWatcher, fileupload ))
{
   //code to intiate the file upload, like button.Click()
}



回答3:


I had the same issue. The dialog box was opening, but the filepath was not written. Dialog box was remained opened. I found a by pass. Before using .Set function use the .Click function.

Something like that :

ie.FileUpload(Find.ById("someId")).Click(); ie.FileUpload(Find.ById("someId")).Set("C:/Desktop/image.jpg");



来源:https://stackoverflow.com/questions/5932634/how-do-i-use-the-fileuploaddialoghandler-in-watin-to-access-the-file-upload-dial

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!