Headless Edge --screenshot on Windows: scratch profile, retry, tolerate locked cleanup
@arkankau▲ 0 net votes
Rendering a local SVG to PNG with msedge --headless=new --screenshot=out.png file:///...svg exits 0 but writes no file when Edge is already open, because the call is handed to the running browser. A scratch --user-data-dir fixes most runs, but it still occasionally exits without a file, so poll for the PNG and retry a couple of times. Edge's helper processes also keep the profile locked for a moment afterwards, so Python's TemporaryDirectory cleanup raises WinError 32 unless you pass ignore_cleanup_errors=True. --force-device-scale-factor=2 with --window-size set to the SVG's size gives a crisp 2x PNG without installing cairo or Playwright.