firefox "screenshot" command line option
in previous versions of firefox, I was able to create screenshots with the following command line options:
/firefox.exe" -P headless --purgecaches --screenshot raw_weather.png --window-size=1920,1080 -browser "https://www.google.com/search?&q=weather+in+Washington+DC"
however, with the latest version 92.0.1, the "--screenshot" option no longer works. what has changed? what am I doing wrong?
Всички отговори (8)
You may have to create a new profile for running in headless mode.
- /questions/1256647 Headless Firefox doesn't work
Thanks, I did create a new profile and called it "headless", however I'm having the same problem.
The code I posted in the above mentioned thread still works for me with the current release. So you can use this as a test to check with issues for your command line.
- firefox -screenshot test.png https://support.mozilla.org/en-US/questions/firefox -P test-ss -no-remote
Note that "-screenshot" implies "-headless" (so merely -screenshot is sufficient) and your code is also missing the dash before "headless" and that might confuse Firefox. Also make sure you clear the entire profile folder as that worked best for me because headless mode seems to be quite sensitive on how to initialize a profile and a normal profile didn't work.
Location used for the main profile that keeps your personal data (Root Directory on about:profiles).
- C:\Users\<user>\AppData\Roaming\Mozilla\Firefox\Profiles\<profile>
Location used for the disk cache and other temporary files (Local Directory on about:profiles).
- C:\Users\<user>\AppData\Local\Mozilla\Firefox\Profiles\<profile>
thanks for the additional information to try. unfortunately, this does not work as well. when I run the command with the "headless" profile that I created, firefox runs for a few seconds, then immediately exits, without an error message, and fails to write an image. is there a way that I can get more debug information while running this command?
"C:\Program Files\Mozilla Firefox\firefox.exe" -screenshot test.png https://support.mozilla.org/en-US/questions/firefox -P headless -no-remote
Did you try to clear the headless profile in both locations (i.e. no files and folder left) to make it possible for Firefox headless to initialize the profile ?
You can try to run the command in a command window.
yes, I cleared the profile from both local and roaming app data locations, and created a few test profiles as well. when I'm running the firefox commands, I'm using the cmd shell.
I tested it with a new profile created in the current release and cleared the entire profile. The problem might be where the test.png file is saved as that is the default folder that is selected when Firefox is run and you also need write permissions to this folder. So maybe specify the full path for the screenshot image.
Променено на
thank you for the helpful feedback. I verified that I have permission in the directory where I want firefox to write the image file, but still no joy. the disappointing thing is that when firefox runs, it just exits without any error messages, or any clue why it fails to write the image.