rosolko / WebDriverManager.Net

Automatic Selenium Webdriver binaries management for .Net
MIT License
267 stars 84 forks source link

WebDriverManager for .Net - DriverManager + VersionResolveStrategy.MatchingBrowser throws a System.IO.FileNotFoundException #315

Open belugui opened 6 months ago

belugui commented 6 months ago

Hello, I will start by saying that I have used DriverManager for .Net for quite sometime and it has worked Ok for me while executing tests in my local and over SelfHosted or OnPrem VMs where I have control of the Chrome Browser version installed, but nowadays that I am planning to execute tests over Azure Hosted machines is that I require to take advantage of something like the "VersionResolveStrategy.MatchingBrowser" option to pull the right Chrome Driver version (sometimes that one may not be the latest one) to match the Chrome Browser version from the Microsoft's windows-latest image.

In theory, "VersionResolveStrategy.MatchingBrowser" will solve this for me, except that it is throwing a system exception.

Below lines I have tested separatelly with positive results: new DriverManager().SetUpDriver(new ChromeConfig()); new DriverManager().SetUpDriver(new ChromeConfig(), "Latest"); new DriverManager().SetUpDriver(new ChromeConfig(), "122.0.6261.57");

This is the line that when executed, throws the exception: new DriverManager().SetUpDriver(new ChromeConfig(), VersionResolveStrategy.MatchingBrowser);

Here you have the Stack Trace:

Message:  System.IO.FileNotFoundException : C:\Users\xxxxx\AppData\Local\Chromium\Application\chrome.exe

Stack Trace:  FileVersionInfo.GetVersionInfo(String fileName) RegistryHelper.GetInstalledBrowserVersionWin(String executableFileName) ChromeConfig.GetRawBrowserVersion() ChromeConfig.GetMatchingBrowserVersion() DriverManager.GetVersionToDownload(IDriverConfig config, String version) DriverManager.SetUpDriver(IDriverConfig config, String version, Architecture architecture)

Chrome Browser version installed on my local is: 122.0.6261.58 WebDriverManager version in the project is: 2.17.2

rosolko commented 6 months ago

Is this path valid C:\Users\xxxxx\AppData\Local\Chromium\Application\chrome.exe and chrome really exists there? For first it's really strange that you're trying to communicate with chrome but file path points to chromium

andriusrbsy commented 6 months ago

I encountered a similar error on my Windows machine. The issue was that my registry key "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe" was pointing to an outdated version of Chrome installed at "C:\Users\andrius.ramanauskas\AppData\Local\Chromium\Application\chrome.exe" (version 79.0.3918.0), which likely came pre-installed on my PC.

However, my actual Chrome browser is located at "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", and the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe" correctly points to this location.

Deleting the "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe" registry key resolved the issue, and DriverManager started working normally.