1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

SeleniumのChromeバージョンアップ時のエラーを回避する(Chrome for Testingの使い方)

Posted at

SeleniumBasicでのChrome for Testingを実行する方法

1. Chrome for Testing をダウンロードする
下記URLから、使いたいバージョンのChromeをダウンロードする

2. ZIPファイルなので、下記フォルダに解凍する
フォルダ名は「testing」にしました。※Chromeのフォルダ内
C:\Program Files\Google\Chrome\testing

3. VBAスクリプト上でドライバーの開始前にSetBinaryメソッドを追加。引数にtestingフォルダ内のChromeの実行ファイルを指定する

Dim driver As New Selenium.ChromeDriver
' この一文↓を追加
driver.SetBinary "C:\Program Files\Google\Chrome\testing\chrome.exe"
driver.Start
driver.Get "https://www.google.com/?hl=ja"    

4. Chromeが起動すると下記のように「自動テスト専用です。」という文言が追加される。
image.png

背景

2023年6月12日にGoogleはブラウザー自動化に特化した「Chrome for Testing」を発表しました。

これを使えば、バージョン違いのエラー※が回避できると思い、使う方法を調べました。

※実行時エラー33
SessionNotCreatedError
This version of chromeDriver only supports Chrome Version

補足

ユーザーのPCにSeleniumBasicをインストールしても、必ずと言っていいほどバージョン違いのエラーが発生して、バージョンの確認方法と更新方法を伝えてもできなくて、結局自分でやっていた作業が解消しそうです。
社内の人に提供するのが中心でしたが、社外の人でも最初のインストールからChrome for Testingでやれば、提供することできそうですね。

ドキュメントだと下記のような記載ですね。PythonやJava等の言語でも可能ですね。

WebDriver.SetBinary Method
Set the path to the browser executable to use

※翻訳)使用するブラウザ実行可能ファイルへのパスを設定します

image.png

Seleniumについて(記事リンク)

  • 概要

  • インストール方法

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?