处理mozilla文件保存对话框 [英] Handle mozilla file save dialog
问题描述
目前我正在处理我需要自动执行文件下载过程的任务,因为我使用的是selenium和Firefox浏览器。
问题是这样的,当我点击保存文件的链接时,会打开文件保存对话框。目前我正在使用sendkeys方法处理此对话框,该方法工作正常但效率不高,因为对于此目的,对话框应该是最顶层的窗口。有些时候,我正在使用其他东西文件下载跳过。这是我的代码。
Currently i am working on task where i need to automate file download process, for this i am using selenium and Firefox browser.
Issue is this when i am clicking on link to save file, there is file-save dialog opened. Currently i am handling this dialog using sendkeys method, which is working fine but not efficient way because for this purpose that dialog should be top most window. And some time when i am using other things file downloading got skip. Here is my code.
public static void HandleDialogBox(IntPtr hwndl)
{
try
{
WndSearcher.SetForegroundWindow(hwndl);
Thread.Sleep(200);
SendKeys.SendWait("%s");
//SendKeys.Flush();
if (hwndl != WndSearcher.GetForegroundWindow())
WndSearcher.SetForegroundWindow(hwndl);
SendKeys.SendWait("%a");
//SendKeys.Flush();
//if (hwndl != WndSearcher.GetForegroundWindow())
// WndSearcher.SetForegroundWindow(hwndl);
//SendKeys.SendWait("{TAB}");
//SendKeys.Flush();
if (hwndl != WndSearcher.GetForegroundWindow())
WndSearcher.SetForegroundWindow(hwndl);
SendKeys.SendWait("{ENTER}");
SendKeys.Flush();
}
catch (Exception)
{
throw;
}
}
我想使用winapi 处理此对话框。我也使用winapi / pinvoke从事桌面自动化工作,我可以得到其他windows子控件(按钮,复选框等),但是我无法让孩子控制这个文件保存对话框。甚至间谍++也没给我孩子控制这个对话框。
请帮帮我。
先谢谢。
CP Expert的意见要求。
I want to handle this dialog using winapi. I have also worked on desktop automation using winapi/pinvoke, and i can get other windows child control (button,checkbox etc) but i am unable to get child control of this file-save dialog.Even spy++ is also not giving me child control of this dialog.
Please help me.
Thanks in Advance.
CP Expert's Opinion Required.
推荐答案
@ MuhammadUSman1
您可以使用autoIT进行此类处理,因为autoIT很好,你可以轻松处理。
只需要在selenium中运行exe文件。
@MuhammadUSman1
You can use autoIT for this type of handling because autoIT is good and you can handle easily.
Just you have to run exe file in selenium.
这篇关于处理mozilla文件保存对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!