Search code examples
c#seleniumgoogle-chromewebdriver-manager

WebDriverManager.net - updating chrome driver automatically fails


I am having problems with updating chromedriver ( using WebDriverManager ). Trying with below code:

 private static WebDriver getChromeDriver()
    {
        ChromeOptions options = new ChromeOptions();

        options.AddUserProfilePreference("profile.default_content_setting_values.images", 2);
        options.AddArguments("headless", "--blink-settings=imagesEnabled=false");
        options.AddArguments("--disable-extensions"); // to disable extension
        options.AddArguments("--disable-notifications"); // to disable notification
        options.AddArguments("--disable-application-cache"); // to disable cache

        new DriverManager().SetUpDriver(new ChromeConfig(), VersionResolveStrategy.MatchingBrowser);

        try
        {
            return new ChromeDriver(options); 

        }
        catch (Exception e)
        {
            MessageBox.Show("Error loading Chrome. Need to update driver?");
            throw;
        }
    }

Code returns Exception. As far as i understand new DriverManager().SetUpDriver(new ChromeConfig(), VersionResolveStrategy.MatchingBrowser); should take care of driver version?.

I am not experienced enough with this project. It uses Selenium to automatically log in to a website, but i would like to check and update chrome drivers first.


Solution

  • There are issues with WebDriverManager.Net for both Chrome and Edge. Long story short, the URLs that WebDriverManager uses to download an updated driver have changed, but the NuGet package has not been updated to use the new URLs.

    Issues have been opened on GitHub to address this:

    As of writing this answer, it appears the auto-update feature of WebDriverManager.Net is broken because Google and Microsoft have changed the URLs used to download the zip files containing web driver executables.