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!