rosolko/WebDriverManager.Net

exe not downloading into the designated folder

jdsimcock opened this issue · 1 comments

Related to issue #167 and the comment from Pookalton in that I need to have the driver download into a folder that the user has authority to write to. My deployed application installs into a sub-folder of the "Program Files (x86)" which after installation, the user does not have access to update. Therefore trying to download driver into a sub-folder of the Roaming Application folder, which the user can update. The folders are created by WebDriverManager but, the needed "msedgedriver.exe" does not appear.

var RoamingAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
RoamingAppDataPath += "myAppName\\EdgeDriver\\LATEST";

new WebDriverManager.DriverManager().SetUpDriver(
"https://msedgedriver.azureedge.net/LATEST_STABLE",
Path.Combine(RoamingAppDataPath, "msedgedriver.exe")
);

Also your README "Manual way" seems to show the now obsolete syntax i.e.

new DriverManager().SetUpDriver(
"https://chromedriver.storage.googleapis.com/2.25/chromedriver_win32.zip",
Path.Combine(Directory.GetCurrentDirectory(), "chromedriver.exe"),
"chromedriver.exe"
);

rather than the current supported syntax of

new DriverManager().SetUpDriver(
"https://chromedriver.storage.googleapis.com/2.25/chromedriver_win32.zip",
Path.Combine(Directory.GetCurrentDirectory(), "chromedriver.exe")
);

Really keen to get this working and to be able to make use of your otherwise very helpful code :-).

OK so I think this issue should be closed as I looked at one of the already closed issues and found some nice code and tried that in with mine and it worked. My working code in case that helps anyone else is:

IDriverConfig config = (IDriverConfig)Activator.CreateInstance(typeof(EdgeConfig));

string latestVersion = config.GetLatestVersion();
string url = config.GetUrl64().Replace("<version>", latestVersion);
string msEdgeDriverDirectoryName = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
msEdgeDriverDirectoryName += $"\\myAppName\\Edge\\{latestVersion}\\X64";
string binaryPath = Path.Combine(msEdgeDriverDirectoryName, config.GetBinaryName());

DriverManager mgr = new DriverManager();
mgr.SetUpDriver(url, binaryPath);

Thank you very much for this code as my app would not be possible without it.