|
|
|
@@ -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); |
|
|
|
} |
|
|
|
} |
|
|
|
|