From 7b46b260033e0f2462d0a5280d79aa8e922a8a29 Mon Sep 17 00:00:00 2001 From: "sosuke.iwabuchi" Date: Wed, 15 Nov 2023 10:03:51 +0900 Subject: [PATCH] =?UTF-8?q?chrome=E3=81=AE=E3=83=90=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E5=9B=BA=E5=AE=9A=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CSVDownloader/Web/DriverFactory.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/CSVDownloader/Web/DriverFactory.cs b/CSVDownloader/Web/DriverFactory.cs index de523f5..af97803 100644 --- a/CSVDownloader/Web/DriverFactory.cs +++ b/CSVDownloader/Web/DriverFactory.cs @@ -10,12 +10,12 @@ using SeleniumExtras.WaitHelpers; namespace CSVDownloader.Web { class DriverFactory { - public static ChromeDriver GetDriver() - { + public static ChromeDriver GetDriver() { CreateDir(); var options = new ChromeOptions(); // options.AddArgument("--headless"); + options.BinaryLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\chrome-win64\\chrome.exe"; String download_dir = GetTmpDownloadDir(); options.AddUserProfilePreference("download.default_directory", download_dir); ChromeDriver driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), options); @@ -26,28 +26,23 @@ namespace CSVDownloader.Web { return driver; } - public static String GetTmpDownloadDir() - { + public static String GetTmpDownloadDir() { return Path.GetFullPath("tmp_download"); } - public static String GetDownloadDir() - { + public static String GetDownloadDir() { return Path.GetFullPath("download"); } - private static void CreateDir() - { + private static void CreateDir() { String tmpdownload_dir = GetTmpDownloadDir(); String download_dir = GetDownloadDir(); - if (!Directory.Exists(tmpdownload_dir)) - { + if (!Directory.Exists(tmpdownload_dir)) { Directory.CreateDirectory(tmpdownload_dir); } - if (!Directory.Exists(download_dir)) - { + if (!Directory.Exists(download_dir)) { Directory.CreateDirectory(download_dir); } }