Firefox を headlessで起動


Xvfbが不要になってありがたい。

起動

起動
firefox --headless \
  "https://yahoo.co.jp"

画面キャプチャ

起動
firefox --headless \
 --screenshot "a.png" \
  "https://yahoo.co.jp"

firefoxが既に起動しています の対応

  • profile を新規で指定すればよい。
起動
mkdir ./profile/

firefox --headless \
 --profile ./profile/ \
 --screenshot "a.png" \
  "https://yahoo.co.jp"

*** You are running in headless mode. 表示を消す

この表示を消したい場合は以下

起動
firefox --headless \
 --profile ./profile/ \
 --screenshot "a.png" \
  "https://yahoo.co.jp" 2>/dev/null