VBA Chrome Dev Tool screenshot

Viewed 30

I am working on an automation project. I want to do full page (scroll down) screenshot. While the Chrome default Developer Tool (Ctr+Shift+i, Ctr+Shift+p, >capture full size screenshot) does a great job. However, is it possible to pass this instruction in VBA? I am using https://github.com/longvh211/Chromium-Automation-with-CDP-for-VBA

I have tried using VBA's sendkey methods but result is not ideal as the page is long (scroll down to one more screen). Should I use the Page.captureScreenshot() method? i.e. save the output to a string, and save the string as a PNG file.

Unable to get the output as img_string is empty:

Dim objBrowser As New clsBrowser
Dim img_string As String
Dim bytes() As Byte

objBrowser.start "edge", cleanActiveSession:=True
        'By default, the new window is minimized, use .show to bring it out
objBrowser.show
    'Navigate and wait    'The wait method, if till argument is omitted, will by default wait until ReadyState = complete
objBrowser.navigate "https://www.livingwaters.com/movie/the-atheist-delusion/"
objBrowser.wait till:="interactive" 'only need to wait until page is interactable. Refer to definition for other options

img_string = objBrowser.jsEval("await page.captureScreenshot()")
0 Answers
Related