![](/img/trans.png)
[英]Selenium: download file in Internet Explorer to specified folder without direct link, without Windows Forms, without AutoIt or Robot
[英]How to Download file in Internet Explorer with selenium driver using AutoIT library in C#?
我想在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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.