Просмотр исходного кода

chromeのバージョン固定化

master
sosuke.iwabuchi 2 лет назад
Родитель
Сommit
7b46b26003
1 измененных файлов: 7 добавлений и 12 удалений
  1. +7
    -12
      CSVDownloader/Web/DriverFactory.cs

+ 7
- 12
CSVDownloader/Web/DriverFactory.cs Просмотреть файл

@@ -10,12 +10,12 @@ using SeleniumExtras.WaitHelpers;


namespace CSVDownloader.Web { namespace CSVDownloader.Web {
class DriverFactory { class DriverFactory {
public static ChromeDriver GetDriver()
{
public static ChromeDriver GetDriver() {
CreateDir(); CreateDir();


var options = new ChromeOptions(); var options = new ChromeOptions();
// options.AddArgument("--headless"); // options.AddArgument("--headless");
options.BinaryLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\chrome-win64\\chrome.exe";
String download_dir = GetTmpDownloadDir(); String download_dir = GetTmpDownloadDir();
options.AddUserProfilePreference("download.default_directory", download_dir); options.AddUserProfilePreference("download.default_directory", download_dir);
ChromeDriver driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), options); ChromeDriver driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), options);
@@ -26,28 +26,23 @@ namespace CSVDownloader.Web {
return driver; return driver;
} }


public static String GetTmpDownloadDir()
{
public static String GetTmpDownloadDir() {
return Path.GetFullPath("tmp_download"); return Path.GetFullPath("tmp_download");
} }


public static String GetDownloadDir()
{
public static String GetDownloadDir() {
return Path.GetFullPath("download"); return Path.GetFullPath("download");
} }


private static void CreateDir()
{
private static void CreateDir() {
String tmpdownload_dir = GetTmpDownloadDir(); String tmpdownload_dir = GetTmpDownloadDir();
String download_dir = GetDownloadDir(); String download_dir = GetDownloadDir();


if (!Directory.Exists(tmpdownload_dir))
{
if (!Directory.Exists(tmpdownload_dir)) {
Directory.CreateDirectory(tmpdownload_dir); Directory.CreateDirectory(tmpdownload_dir);
} }


if (!Directory.Exists(download_dir))
{
if (!Directory.Exists(download_dir)) {
Directory.CreateDirectory(download_dir); Directory.CreateDirectory(download_dir);
} }
} }


Загрузка…
Отмена
Сохранить