I keep searching on internet from different sources but still unable to launch a specific version of Chrome For Testing using ChromeDriver using C# in VS 2022. Sadly it's not clearly explained on Selenium website. Anyone knows how to do that?
How to launch Chrome For Testing using ChromeDriver using C#
1.8k Views Asked by tala9999 At
2
There are 2 best solutions below
0
On
I was facing the same problem. You can use the BinaryLocation property of the ChromeOptions class.
I cannot use Driver Manager or download anything from the internet when running our system.
Our system runs on Windows (development in Win10, production Windows server), targeting .NET6.
I have downloaded the stable versions of Chrome for testing (CFT) and chromedriver (119.0.6045.105).
Let's assume I have downloaded the files to the c:\test\chrome-for-testing\119.0.6045.105 and c:\test\chromedriver\119.0.6045.105 folders respectively.
var service = ChromeDriverService.CreateDefaultService(@"c:\test\chromedriver\119.0.6045.105");
// configure chrome capabilities
var options = new ChromeOptions();
options.BinaryLocation = @"c:\test\chrome-for-testing\119.0.6045.105\chrome.exe";
// create driver
var driver = new ChromeDriver(service, options);
And that's it. Hope that helps.
Finally here is the way Please note I'm running this on VS 2022 of Windows 11
You cannot initialize ChromeDriver with the path to ChromeDriver. Instead, you have to add the path to ChromeDriver to Windows' user/system variables first.
After that, you can launch a specific version of Chrome For Testing using this code:
Watch this video for more details: https://www.youtube.com/watch?v=NSmEaOEeusE, but it's in Java. Enjoy coding!