Selenium Chromedriver アップデート

PC

PythonでのSeleniumのChromedriverの件です。

昨日までサクサク動いていたプログラムが急に動かなくなったぞ?

えーと、
「selenium this version of chromedriver only supports~」

そうか、またChromeのバージョンアップか。
ということで、ドライバーをアップデートするわけですが、そのやり方については以前触れました。

でも、いい加減面倒になってくるんですね。
自動でやってくれないかなー、と。

そうしたら、同じように考える人はいるようです。
毎回プログラムの起動時に、対応しているChromedriverかどうかチェックしてくれて、対応していなかったらアップデートしておいてくれるライブラリがありました。

webdriver_manager

というものですが、普通にpipでインストールできます。

pip install webdriver-manager

あとは、ブラウザを立ち上げるプログラムを少し書き換えるだけです。

from webdriver_manager.chrome import ChromeDriverManager

を冒頭に追加して、

driver = webdriver.Chrome()

だったところを

driver = webdriver.Chrome(ChromeDriverManager().install())

に変えるだけです。
これで手動アップデートとはおさらば。
一つ難点があるとすれば、ブラウザが立ち上がるたびに、

[WDM] – Current google-chrome version is 89.0.4389
[WDM] – Get LATEST driver version for 89.0.4389
[WDM] – Driver [/Users/*****/drivers/chromedriver/mac64/89.0.4389.87/chromedriver] found in cache

といった表示がされるので、ちょっとウザいということくらいでしょうか。

Selenium本

Hands-On Web Scraping with Python Perform advanced scraping operations using various Python librarie
Hands-On Web Scraping with Python Perform advanced scraping operations using various Python librarie 4,304円(税込)【送料込】

楽天Kobo電子書籍ストア

<p><b>Collect and scrape different complexities of data from the modern Web using the latest tools,

Test-Driven Development with Python Obey the Testing Goat: Using Django, Selenium, and JavaScript【電子
Test-Driven Development with Python Obey the Testing Goat: Using Django, Selenium, and JavaScript【電子 3,529円(税込)【送料込】

楽天Kobo電子書籍ストア

<p>By taking you through the development of a real web application from beginning to end, the second

Selenium自?化??完全指南:基于Python【電子書籍】
Selenium自?化??完全指南:基于Python【電子書籍】 5,553円(税込)【送料込】

楽天Kobo電子書籍ストア

<p>本?共有19章。第1〜10章介?Selenium IDE、Selenium WebDriver、Selenium Grid、Appium等工具的?用。第11〜16章介?自?化????的??及模式

洋書 Paperback, Test-Driven Development with Python: Obey the Testing Goat: Using Django, Selenium, an
洋書 Paperback, Test-Driven Development with Python: Obey the Testing Goat: Using Django, Selenium, an 12,817円(税込)【送料別】

Glomarket

*** We ship internationally, so do not use a package forwarding service. We cannot ship to a package

Selenium and Appium with Python Build robust and scalable test automation frameworks using Selenium,
Selenium and Appium with Python Build robust and scalable test automation frameworks using Selenium, 1,597円(税込)【送料込】

楽天Kobo電子書籍ストア

<p>Appium and Selenium are popular open-source frameworks widely used for test automation in the sof

楽天ウェブサービスセンター
タイトルとURLをコピーしました