'How to publish ChromeDriver.exe to drop location when using Floating Version (*) in project file (.csproj)

Trying to have the latest version of ChromeDriver without having to always update the Nuget: Selenium.WebDriver.ChromeDriver in drop folder.

For this we used the floating variable: "*" for version as below in my project .csproj file:

<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="*"/>

or

<PackageReference Include="Selenium.WebDriver.ChromeDriver">
  <Version>*</Version>
</PackageReference>

This works in local wherein on build, the latest version of available chromedriver ( currently: 99.0.4844.5100 ) is installed into local machine in bin/debug (or whichever)

but using a floating variable doesn't copy the latest ChromeDriver.exe (or any version of ChromeDriver.exe) into the build drop when checked-in (whereas when the version is hardcoded or anything other than *, its copied to build drop upon check-in).

Any other way of using floating variable works: For example:

  1. using 99* works (but this will always fix it to any version starting with 99, and will not get the next highest version when the next version 100 will release
  2. using []/(]/()/[) works but again will not get the highest acceptable stable version
  3. hardcoding the version like 99.0.4844.5100 works

Note: My goal is to

  1. Not manually keep updating Selenium.WebDriver.ChromeDriver in my projects
  2. Have latest publish to build drop folder upon checkin
  3. Copy build files to a remote VM X
  4. Use the latest ChromeDriver.exe copied onto the machine X to run Selenium Test Cases using latest Nuget without manually and continuously checking and updating Nuget SeleniumWebDriver.ChromeDriver for a new version.

How can we move latest highest version of chromedriver.exe to build drop upon check-in without having to manually regularly updating the Nuget package: Selenium.WebDriver.ChromeDriver ? (preferebly by using * in version of csproj) ?



Solution 1:[1]

You may not reference Selenium.WebDriver.ChromeDriver directly. You may reference

<PackageReference Include="Selenium.WebDriver" Version="4.1.0" />
<PackageReference Include="Selenium.Support" Version="4.1.0" />

and any version of chrome driver will be available for you without the need to update the Selenium.WebDriver.ChromeDriver package version.

To update the driver binary on your machine to the latest version - you may use https://github.com/rosolko/WebDriverManager.Net

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 shatulsky