LoginSignup
2
2

More than 3 years have passed since last update.

ChromeDriver 通知バー消す方法 (Java)

Last updated at Posted at 2020-06-26

Selenium (ChromeDriver) での「自動テストソフトウェアによって制御されています]という通知バーを削除する方法

無題.png

この表示邪魔ですよねー。

通知バーを消すと、デベロッパーモードを無効にしますか?とポップアップが出てしまい、
なかなか方法が見つかりませんでしたが、合わせ技で通知バーを消すことができたので記事に起こしておきます。

import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("excludeSwitches", new String[] { "enable-automation" });
options.setExperimentalOption("useAutomationExtension", false);
WebDriver driver = new WebDriver(options);

パスワード保存のポップアップ非表示は
WebDriver driver = new WebDriver(options);
の直前に以下のコードを追記すればできます。

Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("credentials_enable_service", false);
prefs.put("profile.password_manager_enabled", false);
options.setExperimentalOption("prefs", prefs);

これを丸ごとコードに記述することで通知バーが見事に消えます。

2
2
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
2
2