2

I want to take a screenshot of a webpage from the command line. I have managed to achieve this in Chrome and Firefox using the following command:

"c:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --headless --screenshot="C:\tmp\screen.png" --window-size=1280,720 "https://bbc.co.uk/news"

I'm trying to do the same using Microsoft Edge but can't seem to find any info. My thinking is that 99% of Windows machines will have this preinstalled and in the same location.

2
  • Have you tried these command line options with the latest version of Edge? Commented May 18, 2020 at 9:47
  • Yes. Trying to run against the Edge exe has no effect. Even trying to just run the Edge exe with no arguments from the command line has no effect. Commented May 18, 2020 at 10:02

2 Answers 2

0

Just a guess, but Edge may simply not implement these features (at least not yet).

Edge based on Chromium has existed for just about a year (as of this writing) but the "official" build wasn't even released until January 2020. And this Microsoft Tech Community post seems to indicate built-in screenshots weren't available then, either.

4

The latest Edge Chromium versions work pretty well to snapshot a page, even on an older server OS, such as Windows 2012R2:

"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --headless --disable-gpu --window-size=1280,720 --screenshot="C:\tmp\screen.png" "https://bbc.co.uk/news" 

Similarly, you can also create a PDF from a web page by changing the screenshot argument:

"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --headless --disable-gpu --window-size=1280,720 --print-to-pdf-no-header --print-to-pdf="C:\tmp\screen.pdf" "https://bbc.co.uk/news" 
3
  • Any reason for the downvote? I'm performing this successfully in production with 10,000 customers, and I'd like to know if this technique has a particular issue. Commented Feb 15, 2022 at 18:00
  • (Not the downvoter) Have you had issues with the process not closing when you're done running this command? Chrome closes itself when it's done, but Edge appears to be sticking around. Commented Apr 13, 2022 at 12:43
  • @seadoggie01 I just checked our primary app servers, one has it loaded, one does not. But it doesn't seem to be hurting anything. Perhaps it closes after a period of time. I know it can stay open if you have service workers, but I don't think we have any of those configured. Commented May 6, 2022 at 23:37

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.