2

It seems like for Chrome and Edge, I can simply match my browser but is there a way to do the same with Firefox? I see from the documentation here, it only works for Chrome (which isn't true since it works for Edge). I don't have control of updating the browsers so if the case arises, how can I automatically download the correct driver version? I don't want to manually handle this process. Below is the issue for Firefox.

public void DownloadDrivers(EDriver driver)
{
   if(driver == EDriver.Edge)
   {
      _ = new DriverManager().SetUpDriver(new EdgeConfig(), VersionResolveStrategy.MatchingBrowser);
   }
   else if(driver == EDriver.Firefox)
   {
      // VersionResolveStrategy.MatchingBrowser is equal to "MatchingBrowser"
      // If I don't pass it in, it will take the default value of "Latest"
      _ = new DriverManager().SetUpDriver(new FirefoxConfig(), VersionResolveStrategy.MatchingBrowser);
   }
   else if(driver == EDriver.Chrome)
   {
      _ = new DriverManager().SetUpDriver(new ChromeConfig(), VersionResolveStrategy.MatchingBrowser);
   }
}

2 Answers2

0

It seems like this is actually a bug that has been raised as an issue in the GitHub repo

The issue seems to be that for edge and Chrome, the driver version and major version of the browser match (as in major version 105 of the browser will be version 105 of the driver).

The same isn't for Firefox (major version 104 of the Firefox browser will be 0.31 of the driver)

https://github.com/rosolko/WebDriverManager.Net/issues/189

0

There is no such thing as a matching version for Firefox. The GheckoDriver version is independent from the version of Firefox that you are running. Instead, use the "Latest" version strategy:

new DriverManager().SetUpDriver(new FirefoxConfig(), VersionResolveStrategy.Latest);

As you noted in your question, the "Latest" version strategy is the default.

The VersionResolveStrategy is an incomplete abstraction, unfortunately. Each browser vendor is free to create their own versioning schemes for their browsers and web drivers. Fixing this in WebDriverManager.Net would basically require a rewrite of most of the library, since the version control strategy is tightly coupled to the browser vendor.

The existing VersionControlStrategy class gives the impression that each browser vendor supports this, when in fact this isn't true.

Greg Burghardt
  • 17,900
  • 9
  • 49
  • 92
  • No that's incorrect. The issue is the underlying code. It assumes the driver and browser versions match (meaning version 100 of the browser will be version 100 of the driver). In Firefox, it assumes the same so version 100 will try downloading the driver with a version of 100 (which isn't correct). I put my answer above and the issue to the bug. –  Sep 29 '22 at 14:18
  • 1
    @ThisIsMyAlias: that's why I said the VersionResolveStrategy is an incomplete abstraction. It simply doesn't apply to Firefox, because that is not how the browser vendor determines browser and driver versions. There never was such a thing as "matching browser version" for GeckoDriver. A matching version means browser version 100.x should use web driver version 100.x. GeckoDriver is at versions 0.x, even though Firefox is at version 100+. This, of course, depends on how you interpret "matching version". Most people assume at least major versions match, hence my answer. – Greg Burghardt Sep 29 '22 at 15:01
  • 1
    @ThisIsMyAlias: have a look at the [GeckoDriver support for Firefox](https://firefox-source-docs.mozilla.org/testing/geckodriver/Support.html). You will see zero correlation between browser and driver version. At least nothing that you can programmatically connect using version numbers alone, which is the intent of the MatchingVersion resolve strategy. – Greg Burghardt Sep 29 '22 at 15:04
  • 1
    But what I am saying is the code used in the WDM is making that exact assumption - for all browsers, it simply assumes the driver version will be the same (which I am aware for Firefox, it isn't the case and old versions of Edge/Chrome). The nice thing about Edge/Chrome is they have an API you can call and pass your browser version in which it will return the driver version that will match (although I "think" WDM isn't even using the API (I can't remember) and just assumes matching the browser version will work which is not correct - should be using the API). Firefox doesn't have an API (yet). –  Sep 29 '22 at 21:25