我想在IE中的Selenium自动化过程中下载一个文件,到目前为止,我通过在C#类文件中添加AutoIt库来单击按钮后尝试了以下代码,但是这个不起作用。谁能帮助我所缺少的?
提前谢谢。
IntPtr temp = AutoItX.WinGetHandle("[Class:IEFrame]");
AutoItX.ControlGetHandle(temp, "[Class:DirectUIHWND]");
Thread.Sleep(1000);
AutoItX.WinActivate(temp);
AutoItX.ControlClick("[Class:DirectUIHWND]", "", "");
AutoItX.ControlSend("", "", "[ClassNN:DirectUIHWND]", "{F6}");
Thread.Sleep(500);
AutoItX.ControlSend("", "", "[Class:DirectUIHWND]", "{TAB}");
Thead.Sleep(500);
AutoItX.ControlSend("", "", "[Class:DirectUIHWND]", "{ENTER}");
Thread.Sleep(500);
我通常指示Selenium单击按钮/链接下载文件,以便出现Windows资源管理器窗口,并使用AutoIT从那里获取它。
像这样:
driver.[locate the button/link that downloads the file]
driver.[click that button/link]
(perhaps a wait here)
system.[fire up the autoIT executable that handles the windows explorer window]
carry on from there