LoginSignup
4
4

More than 5 years have passed since last update.

Seleniumでページ巡回してconsole.logを保存

Posted at

概要

ページ全体で、https対応しているか、M70対応(信頼されなくなる証明書を使っているページがあるか)を確認したくて、Seleniumでページを巡回して、Chromeのconsole.logを自動で保存する仕組みを作成。

環境

  • macOS(sierra)
  • node.js(9)
  • chromedriver 2.37.0
  • selenium-webdriver 4.0.0-alpha.1(何も考えずにインストールしたら、alphaだった)

Chromeのconsole.logを保存するための起動オプション(mac)

open /Applications/Google\ Chrome.app --args --enable-logging --log-level=0

SeleniumのWebDriverの起動方法(node.js)

  • 検索しても、言語が違ったり、バージョンが違ったりして、設定方方法をなかなかみつけらず。試行錯誤したら動いた。
const capabilities = webdriver.Capabilities.chrome()
const chromeOptions = {
    'args': ['enable-logging'],
}
capabilities.set('chromeOptions', chromeOptions)

let driver = await new webdriver.Builder()
.withCapabilities(config['capabilities'])
.build()

動作イメージ

360p_gif.gif
https://youtu.be/2RXbYS8AKDw

ソースコード(github)

https://github.com/uebusin/save_chrome_log
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4