簡體   English   中英

如何在 IE11 中自動下載文件

[英]How to automate file download in IE11

如果 IE 版本為 8 或以下,則可以使用以下代碼自動下載文件並保存在 IE 中:

AutomateWinWindow objfileWindow;
AutomateWinWindow objfileSaveAs;

objfileWindow = new AutomateWinWindow("File Download", "#32770", "1", "File Download", "");
CodedUI_Automation.AutomateWinButton.AutomateWinButtonMethod(objfileWindow, "Save", "File Download", "Click");

objfileSaveAs = new AutomateWinWindow("Save As", "#32770", "1", "Save As", "");
templatesourcefile = ManageSaveAsWindow(objfileSaveAs, TemplateInputPath, offeringID, "Excel");            

但是對於最新版本的文件下載窗口還沒有到來。 它作為一個沒有任何名稱和 ID 的小彈出窗口出現。 如果有人能在這方面幫助我,那將是一個很大的幫助。

您提供的代碼對我來說看起來不像純編碼的 ui。 還請提供 AutomateWinWindow 和 ManageSaveAsWindow 的類定義。

絕對可以處理文件的保存。 我會推薦兩件事。

  1. 您可以使用 Coded UI 工具中的檢查器來檢查要單擊或操作的內容。

  2. 您可以使用檢查工具,如檢查工具。

通常我還建議使用記錄和播放來查看它的結果,但似乎記錄和播放不適用於此(至少不在我的機器上)。

使用內置的檢查工具,我可以看到通知工具欄具有以下屬性:

ControlType: ToolBar
TechnologyName: MSAA
Name: Notification

使用檢查器中的導航箭頭,您可以移動到子元素或同級元素。

我能夠監視可用於保存文件的 UISaveSplitButton。

ControlType: SplitButton (important! not a button, but a split button)
TechnologyName: MSAA
Name: Save

使用像CodedUI Fluent這樣的搜索抽象(我寫的東西,類似於CUITe ),它看起來像:

WinToolBar notificationBar = browserWindow.Find<WinToolBar>(WinToolBar.PropertyNames.Name, "Notification", PropertyExpressionOperator.EqualTo);

WinSplitButton saveButton = notificationBar.Find<WinSplitButton>(WinButton.PropertyNames.Name, "Save", PropertyExpressionOperator.EqualTo);

saveButton.Click();

僅使用 CodedUI,它看起來像這樣(我更喜歡上述抽象中的流暢搜索語法,但為了完整性):

WinToolBar notificationBar = new WinToolBar(browserWindow);
notificationBar.SearchProperties.Add(WinToolBar.PropertyNames.Name, "Notification", PropertyExpressionOperator.EqualTo);

WinSplitButton saveButton = new WinSplitButton(notificationBar);
saveButton.SearchProperties.Add(WinButton.PropertyNames.Name, "Save", PropertyExpressionOperator.EqualTo);

Mouse.Click(saveButton);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM