Не удалось установить правильный путь к проекту в net-core, что приводит к ошибке селен: файл geckodriver.exe не существует - PullRequest
0 голосов
/ 02 февраля 2019

В строке 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);
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...