Home > Net >  WebDriverManager download matching version of firefox driver
WebDriverManager download matching version of firefox driver

Time:09-30

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);
   }
}

CodePudding user response:

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

CodePudding user response:

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.

  • Related