From 06f210b6e43a8e3c81e8d8451b68235e45357e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Machulda?= Date: Thu, 15 Aug 2024 11:42:59 +0200 Subject: [PATCH] Disable search engine choice pop-up in Chrome --- src/Selenium/CapabilitiesResolver.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Selenium/CapabilitiesResolver.php b/src/Selenium/CapabilitiesResolver.php index 0c83118..5b36547 100644 --- a/src/Selenium/CapabilitiesResolver.php +++ b/src/Selenium/CapabilitiesResolver.php @@ -2,6 +2,7 @@ namespace Lmc\Steward\Selenium; +use Facebook\WebDriver\Chrome\ChromeOptions; use Facebook\WebDriver\Remote\DesiredCapabilities; use Facebook\WebDriver\Remote\WebDriverBrowserType; use Facebook\WebDriver\Remote\WebDriverCapabilityType; @@ -101,6 +102,9 @@ protected function setupBrowserSpecificCapabilities( case WebDriverBrowserType::IE: $capabilities = $this->setupInternetExplorerCapabilities($capabilities); break; + case WebDriverBrowserType::CHROME: + $capabilities = $this->setupChromeCapabilities($capabilities); + break; } return $capabilities; @@ -113,4 +117,14 @@ protected function setupInternetExplorerCapabilities(DesiredCapabilities $capabi return $capabilities; } + + private function setupChromeCapabilities(DesiredCapabilities $capabilities): DesiredCapabilities + { + $chromeOptions = new ChromeOptions(); + // Disable search engine choice pop-up which appears in Chrome 127+ + $chromeOptions->addArguments(['--disable-search-engine-choice-screen']); + $capabilities->setCapability(ChromeOptions::CAPABILITY, $chromeOptions); + + return $capabilities; + } }