1

In order to avoid browser driver version mismatch issue every time I execute my Selenium tests using xUnit test runner, I have added below line of code to my .cs file

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

but, when I execute my test, I'm getting below error

SampleXUnitTestProject.FirstSeleniumTests.CorrectTitleDisplayed_When_NavigateToHomePage
Source: FirstSeleniumTests.cs line 25
Duration: 1 ms

Message: 
 System.Net.WebException : The remote server returned an error: (404) Not Found.
Stack Trace: 
 HttpWebRequest.GetResponse()
 ChromeConfig.GetLatestVersion(String url)
 ChromeConfig.GetMatchingBrowserVersion()
 DriverManager.GetVersionToDownload(IDriverConfig config, String version)
 DriverManager.SetUpDriver(IDriverConfig config, String version, Architecture architecture)
 FirstSeleniumTests.ctor() line 18

My test is getting passed if I remove VersionResolveStrategy.MatchingBrowser argument from SetUpDriver, but correct version of drivers matching my current version of installed browsers will be downloaded only when I pass VersionResolveStrategy.MatchingBrowser argument to the SetUpDriver. Can someone help me to resolve the above error?

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using System;
using WebDriverManager;
using WebDriverManager.DriverConfigs.Impl;
using WebDriverManager.Helpers;   
using Xunit;

namespace SampleXUnitTestProject
{
public class FirstSeleniumTests : IDisposable
{
    private IWebDriver _driver;

    public FirstSeleniumTests()
    {
        new DriverManager().SetUpDriver(new ChromeConfig(), VersionResolveStrategy.MatchingBrowser);
        _driver = new ChromeDriver();
        _driver.Manage().Window.Maximize();
    }
    
    [Fact]
    public void CorrectTitleDisplayed_When_NavigateToHomePage()
    {
        _driver.Navigate().GoToUrl("https://lambdatest.github.io/sample-todo-app/");

        Assert.Equal("Sample page - lambdatest.com", _driver.Title);
    }

    public void Dispose()
    {
        _driver.Quit();
    }
}
}
Poovin
  • 164
  • 3
  • 15
  • Did you find out what the issue is? I'm having the same problem. – sashoalm Jul 11 '22 at 12:12
  • We started running into this issue in July 2022. We actually got this with Edge and Chrome. Looks like Microsoft and Google changed the URLs used to fetch new driver versions. See GitHub issues [168](https://github.com/rosolko/WebDriverManager.Net/issues/168) and [174](https://github.com/rosolko/WebDriverManager.Net/issues/174). Not sure if they are related to your problem, since this question was originally asked in October 2021. – Greg Burghardt Jul 12 '22 at 19:33

0 Answers0