0

I'm trying to update my "chromedriver.exe" and my "msedgedriver.exe" when I start my program automatically. I am able to download both exes with their correct versions, but I need to acces to it's versions from my code and I'm having some trouble with edge.

In order to get my chromedriver.exe version I do:

//I get the new version
new DriverManager().SetUpDriver(new ChromeConfig()); 

ChromeDriver driver = new ChromeDriver(); 

try{
 ICapabilities capabilities = driver.Capabilities; 
 string driver_version = (capabilities.GetCapability("chrome") as Dictionary<string, object>)["chromedriverVersion"].toString());
}

This works fine, it gets the chromedriver.exe version fine, the problem is when I try to do the same for my EdgeDriver. THe code is all the same, declaring EdgeDriver instead of ChromeDriver:


new DriverManager().SetUpDriver(new ChromeConfig()); 

EsgeDriverdriver driver = new EdgeDriver(); 

try{
 ICapabilities capabilities = driver.Capabilities; 
 //this is where I cannot find the way of getting the version
 string driver_version = (capabilities.GetCapability("edge") as Dictionary<string, object>)["edgedriverVersion"].toString());
}

I've tried with "edgeDriverVersion" and "msedgedriverVersion", but I can't find the correct way of doing it. I've searched for documentation online but haven't found anything so far. Thank You in advance.

1 Answers1

0

Okay I found the answer to this. If you get your ICapabilities you can print them to show you the info they have. In my case, as mentioned, I was interested about the webdriver version, but you can check any other thing you need about it:

{
  "acceptInsecureCerts": false,
  "browserName": "chrome",
  "browserVersion": "107.0.5304.107",
  "chrome": {
    "chromedriverVersion": "107.0.5304.62 (1eec40d3a5764881c92085aaee66d25075c159aa)"
   (...)
   }
}

This is what Console.WriteLine(capabilities.ToString()); spits. You just have to get the information you need from there. In my case I needed Edge Version so:

{
  "acceptInsecureCerts": false,
  "browserName": "msedge",
  "browserVersion": "107.0.1418.52",
  "ms:edgeOptions": {
    "debuggerAddress": "localhost:50432"
  },
  "msedge": {
    "msedgedriverVersion": "107.0.1418.56 (5b47a5c50066f665a52aa4155d30228091b46135)"
   (...)
   }
}

And to get my msedgeVersion:

string version = (capabilities.GetCapability("msedge") as Dictionary<string, object>)["msedgedriverVersion"].ToString(); 

I hope this helps to someone, got my head burning for some time!

(I deleted some things, just in case you see something missing in the objects).