В строке new FirefoxDriver(options)
Я получаю сообщение об ошибке:
Файл geckodriver.exe не существует ни в текущем каталоге, ни в каталоге переменной среды PATH.
Похоже, что мой каталог не получен правильно, когда я выдаю Directory.GetCurrentDirectory();
, который дает: c:\project-path\
, но должен дать c:\project-path\bin\Debug\netcoreapp2.1\
, где находятся мои Project.Dll
и geckodriver.exe
.
Я пыталсядобавить config.SetBasePath(Directory.GetCurrentDirectory());
к WebHostBuilder()
в Program.cs
, но путь к проекту по-прежнему не изменяется на путь Dll.
Любая помощь приветствуется.
Код проекта:
FirefoxOptions options = new FirefoxOptions();
FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("browser.download.folderList", 2);
profile.SetPreference("browser.download.dir", downloadPath);
profile.SetPreference("browser.download.downloadDir", downloadPath);
profile.SetPreference("browser.download.manager.alertOnEXEOpen", false);
profile.SetPreference("browser.helperApps.neverAsk.saveToDisk",
"text/csv;application/csv;text/x-csv;text/plain;" +
"application/vnd.ms-excel;" +
"application/xls;" +
"application/msexcel;" +
"application/x-xls;" +
"application/json;" +
"application/octet-stream");
options.Profile = profile;
string path = Directory.GetCurrentDirectory();
webDriver = new FirefoxDriver(options);