0

I am trying to get the minimal example answered by Strive Sun to run correctly from the question posted Nov. 21 2019 post by William C titled, "Is it possible to check chromedriver.exe version at runtime in python?"

Here is my code:

# Check webdriver version compatability with Chrome
chrome_path = which("chromedriver")
options = Options()
options.add_argument("version")
driver = webdriver.Chrome(executable_path=chrome_path)
str1 = driver.capabilities["version"]
str2 = driver.capabilities["chrome"]["chromedriverVersion"].split(' ')[0]
print(str1)
print(str2)
print(str1[0:2])
print(str2[0:2])
if (str1[0:2]) != (str2[0:2]):
    print("Please download the correct Chrome driver version!")
driver.close()

Here is my output:

88.0.4324.150
2.43.600210
88
2.
Please download the correct Chrome driver version!

If I run the command from a terminal prompt as follows, I get the following:

chromedriver
Starting ChromeDriver 88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/branch-heads/4324@{#1784}) on port 9515

Can someone point out my mistake? I am running on Windows 10 Pro, and Python version 3.7.9.

Thank you!

Zeus
  • 3,703
  • 3
  • 7
  • 20
FrankG
  • 1
  • 2
  • How did you implement the `which` function, I guess the `chromedriver` path you got is an earlier version. In the new version of `chromedriver` you should use `browserVersion` instead of `version`. – Zeus Feb 17 '21 at 02:22
  • I am trying to get the chromedriver version, so I do not see how browserVersion is pertinent? The Chrome Browser version is being reported correctly. The issue is the chromedriver version! – FrankG Feb 18 '21 at 21:23
  • When I replace "version" with "browserVersion" I get a Key Error: 'browserVersion' – FrankG Feb 18 '21 at 22:41
  • You can refer to [Which ChromeDriver version is compatible with which Chrome Browser version?](https://stackoverflow.com/questions/41133391/which-chromedriver-version-is-compatible-with-which-chrome-browser-version) to check if the Chrome Browser version matches the chromeDriver version. – Zeus Feb 22 '21 at 01:13

0 Answers0