From 67f481c9d5e825f95b78e088140fa23bec208fd4 Mon Sep 17 00:00:00 2001 From: KarmaKamikaze Date: Tue, 24 Sep 2024 17:42:47 +0200 Subject: [PATCH] Try to locate chromium if chrome is not found --- MoxfieldPriceScraper/MoxfieldScraper.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/MoxfieldPriceScraper/MoxfieldScraper.cs b/MoxfieldPriceScraper/MoxfieldScraper.cs index be4f06f..f785435 100644 --- a/MoxfieldPriceScraper/MoxfieldScraper.cs +++ b/MoxfieldPriceScraper/MoxfieldScraper.cs @@ -114,6 +114,7 @@ private void InitializeWebDriver() chromeOptions.AddArgument("--window-size=2560,1440"); // Set window size chromeOptions.AddArgument("--log-level=3"); // Disable logging chromeOptions.AddExcludedArguments("enable-logging"); // Disable logging + chromeOptions.BinaryLocation = GetChromeLocation(); var preferences = new Dictionary { { "profile.managed_default_content_settings.images", 2 } // Disable image loading @@ -125,6 +126,19 @@ private void InitializeWebDriver() Log.Debug("WebDriver initialized with ImplicitWait set to {Timeout}", _elementSeekTimeout); } + /// + /// Gets the location of the Chrome/Chromium browser. + /// + /// + private static string GetChromeLocation() + { + var options = new ChromeOptions + { + BrowserVersion = "stable" + }; + return new DriverFinder(options).GetBrowserPath(); + } + /// /// Logs in to Moxfield with the provided credentials. ///