Hi @spmofulton
It's not that automation browser does not work, but more and more website are build to support modern browsers.
That's one of the reasons I have moved away from it.
I'm wondering what Microsoft's approach will be to "automated browser" - I guess they might ship chromium based, streamlined version of Edge at some point, or just remove the option entirely.
Here you have a working code that downloads file using Chrome, allowing you to specify download folder, and preserving the original file name
1. Chrome - automate "save as" dialog box - my preferred option
In this case:
- Browser: Always ask for a file save location
- Explorer (File Explorer): Show file extensions, this is needed to obtain full name of the file we download (if we do it as in my example)
WebAutomation.LaunchChrome.LaunchChrome Url: $'''https://github.com/microsoft/Windows-universal-samples/releases/download/MicrosoftDocs-Samples/FileAccess.zip''' WindowState: WebAutomation.BrowserWindowState.Normal ClearCache: False ClearCookies: False WaitForPageToLoadTimeout: 60 Timeout: 60 BrowserInstance=> Browser
SET DownloadFolder TO $'''C:\\TEST\\'''
WAIT (UIAutomation.WaitForWindow.ToOpen Window: appmask['Pane \'File access ... - Google Chrome\'']['Window \'Save As\''] FocusWindow: True) FOR 60
UIAutomation.GetElementDetails Element: appmask['Pane \'File access ... - Google Chrome\'']['Edit \'File name:\''] AttributeName: $'''Own Text''' AttributeValue=> FileName
SET FileDownloaded TO $'''%DownloadFolder%%FileName%'''
UIAutomation.PopulateTextField TextField: appmask['Pane \'File access ... - Google Chrome\'']['Edit \'File name:\''] Text: $'''%DownloadFolder%%FileName%''' Mode: UIAutomation.PopulateTextMode.Replace ClickType: UIAutomation.PopulateMouseClickType.SingleClick
UIAutomation.PressButton Button: appmask['Pane \'File access ... - Google Chrome\'']['Button \'Save\'']
WAIT (File.WaitForFile.Created File: FileDownloaded) FOR 60
2. Any browser - get the latest downloaded file from your Downloads folder - my least preferred
In this case your browser needs to be set to always save files to Downloads folder, and never ask for file save location.
System.GetEnvironmentVariable.GetEnvironmentVariable Name: $'''USERPROFILE''' Value=> UserProfile
SET DownloadFolder TO $'''%UserProfile%\\Downloads'''
Folder.GetFiles Folder: DownloadFolder FileFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> FilesBeforeDownload
WebAutomation.LaunchChrome.LaunchChrome Url: $'''https://github.com/microsoft/Windows-universal-samples/releases/download/MicrosoftDocs-Samples/FileAccess.zip''' WindowState: WebAutomation.BrowserWindowState.Normal ClearCache: False ClearCookies: False WaitForPageToLoadTimeout: 60 Timeout: 60 BrowserInstance=> Browser
LABEL CheckFiles
Folder.GetFiles Folder: DownloadFolder FileFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> FilesAfterDownload
Variables.SubtractLists FirstList: FilesAfterDownload SecondList: FilesBeforeDownload OutputList=> FilesDownloaded
IF FilesDownloaded.Count = 1 THEN
SET FileDownloaded TO FilesDownloaded[0]
GOTO FileDownloaded
ELSE
GOTO CheckFiles
END
LABEL FileDownloaded