Replies: 3 comments 1 reply
-
@Pat075, without you providing example code, I can only guess as to what your specific requirements are. Have you seen the following test sub in the test_FileUpDownLoad module? Will that work for you? You will need to specify the name of the attribute of the element referencing the target image. If that is not what you are looking for, then please provide some sample code and then I am sure we can figure something out 🙂. Sub test_download_resource()
'this test uses the DownloadResource method of the WebElement class to download the src to an img element
Dim driver As SeleniumVBA.WebDriver
Dim element As WebElement
Set driver = SeleniumVBA.New_WebDriver
driver.StartChrome
driver.OpenBrowser
driver.NavigateTo "https://github.com/GCuser99/SeleniumVBA/wiki"
driver.Wait 1000
Set element = driver.FindElement(By.CssSelector, "img[alt='SeleniumVBA'")
'if a folder path is specified for fileOrFolderPath, then the saved file inherits the name of the source
element.DownloadResource srcAttribute:="src", fileOrFolderPath:=".\"
driver.CloseBrowser
driver.Shutdown
End Sub |
Beta Was this translation helpful? Give feedback.
-
For example, @Pat075, for downloading your profile icon (the red square) from this page, here is a minimalized code:
|
Beta Was this translation helpful? Give feedback.
-
@Pat075, I'm interested if that solved your issue. Heads up - "DownloadResource" uses "URLDownloadToFileW" to fetch the image from the server once the image url is constructed from the element's "srcAttribute". You mentioned in your OP that you had tried the ansi version of that api function without success... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
With SeleniumVBA on chrome I would like to save an (already downloaded) image to a file. I cannot use a simple "URLDownloadToFileA" windows api to get it because of session (and maybe other) information added to the header that I could not generate. I did not succeed with "Set objHttp = New WinHttp.WinHttpRequest" either.
I discovered that SeleniumVBA includes a "downloadResource" function, can this be used for the purpoise, and how ?
Or is there another (simple?) method?
Thanks for your help!
Beta Was this translation helpful? Give feedback.
All reactions