概要
ページ全体で、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()
動作イメージ
ソースコード(github)
https://github.com/uebusin/save_chrome_log