WatiN 可以在不需要焦点的情况下下载文件吗?
我使用 WatiN 来自动与多个网站进行文件传输(EDI 事务),不幸的是,FTP 或其他自动化友好的方式不是一个选项。对于下载,我使用此示例的变体:
FileDownloadHandler download = new FileDownloadHandler(fullFilename);
using (new UseDialogOnce(ie.DialogWatcher, download))
{
lnkFile.ClickNoWait();
download.WaitUntilFileDownloadDialogIsHandled(15);
download.WaitUntilDownloadCompleted(150);
}
这工作正常,唯一的问题是它需要焦点。下载数十个文件并可能需要一段时间才能完成的情况并不罕见。我在远程会话中运行它,这样我的机器就不会无法使用,但如果有任何方法可以消除对焦点的需要,那就很方便了。
I use WatiN to automate file transfers (EDI transactions) to/from multiple websites, unfortunately FTP or anything more automation-friendly is not an option. For downloads, I use variations of this example:
FileDownloadHandler download = new FileDownloadHandler(fullFilename);
using (new UseDialogOnce(ie.DialogWatcher, download))
{
lnkFile.ClickNoWait();
download.WaitUntilFileDownloadDialogIsHandled(15);
download.WaitUntilDownloadCompleted(150);
}
This works fine, the only problem is that it requires focus. It's not uncommon for there to be dozens of files to download which can take awhile to complete. I run it in a remote session so my machine isn't unusable, but if there's any way to remove the need for focus it'd be convenient.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将使用 WebClient 类,而不是 Watin。 http://msdn.microsoft.com/en-us/library /system.net.webclient.aspx
应该能够使用该类上传和下载文件。
Instead of Watin, I would use the WebClient class. http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx
Should be able to upload and download files using that class.