如何右键单击,将目标另存为使用 WatiN?
我见过使用 WatiN 保存文件的各种解决方案。
我当前的问题与描述的其他问题类似,我需要保存 PDF 文件,但有一个注册表项告诉 IE 自动在新窗口中打开 PDF,而不是保存它。
理想情况下,我可以删除该注册表项并继续。然而,我们的安全策略禁止我这样做(呃。)
我正在寻找一种使用内置 WatiN 机制来查找链接、右键单击和另存为的方法,而不是使用 user32.dll 中的 mouse_event 。
这可能吗?
感谢您的帮助!
I've seen various solutions to saving a file using WatiN.
My current issue is similar to the others described, I need to save a PDF file, but there's a registry key that tells IE to automatically open the PDF in a new window, rather than save it.
Ideally, I could just delete that registry key and move on. However, our security policy forbids me to do that (ugh.)
I'm looking for a way to find a link, right-click, and save-as using a built-in WatiN mechanism, rather than using mouse_event in user32.dll.
Is this possible?
Thanks for the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个非常古老的问题,但作为其他问题的参考,我将发布一个解决方案。
我认为您正在考虑的方法是不正确的。如果您确实有 PDF 的链接,那么您确实拥有 PDF 的地址(即使您必须浏览其他页面才能形成最终的下载 URL,您无论如何都可以使用 Watin 进行模拟) PDF 文件,然后您应该下载它:
此时您应该获得链接 href 字符串(应包含您要下载的文件)
This is a very old question but just as a reference for other I'll post a solution to it.
I think that the approach that you are thinking of is incorrect. If you do have a link to a PDF you do have the address of the PDF (even if you have to go through other pages to form the final download URL, which you can emulate with Watin anyway) if you do have the address of the PDF file then you should just download it:
At this point you should get the link href string (that should contain the file you want to download)