Handling BrowserFileDownload function when it contains a dynamic file location
The BrowserFileDownload function reads a file from a certain location and stores it to the local file system. This is recorded when the Browser Application detects a download being initiated. The BrowserFileDownload function expects at least one parameter which will be the URL of the file to be downloaded. However, if the file URL is changing between runs then the download will fail because the requested URL cannot be found (the best way to check this is happening is to create two separate recordings and check it the URL is changing. If so, this results in the following error on replay:
BrowserEngine: 40 - Cannot download file., INET_E_DOWNLOAD_FAILURE (0x800c0008)
There are three possible ways to resolve this issue:
1. If the pattern is predictable then the URL can be amended in advance, choosing the next appropriate URL for the next replay (for example if the only change was that file was called file1, file2, file3 etc).
2. Sometimes it is not necessary to simulate the actual file being downloaded, but instead a dummy file of a certain size will suffice instead. If this is true then the same URL can always be requested as long as the file will be there.
3. If the URL exists as a property of a control on the page then it can be captured, variablized and submitted as the URL for the BrowserFileDownload function. An example of when this would be possible is if a button needs to be clicked to download the file. This button will likely have a property containing the URL of the file. If so then the BrowserGetProperty function could be used to obtain the URL in advance, then passed into a variable and the variable submitted as the URL for the BrowserFileDownload function like so:
sURL := BrowserGetProperty("//DIV[@textContents='Download File']", "url",);