I'm running a application using selenium, and I want to know actual chrome browser version installed, before running Chrome Driver to avoid any Exception for compatibility reason. I know I can use driver = webdriver.Chrome("path\\to\\chromedriver.exe")
then driver.capabilities['browserVersion']
to show version but if Chrome Driver version differ from actual chrome browser version that's raise an exception.
Thanks
Edited: Actually I found the answer for myself, the solution I found:
from win32com.client import Dispatch
def get_version_via_com(filename):
parser = Dispatch("Scripting.FileSystemObject")
try:
version = parser.GetFileVersion(filename)
except Exception:
return None
return version
if __name__ == "__main__":
paths = [r"C:\Program Files\Google\Chrome\Application\chrome.exe",
r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"]
version = list(filter(None, [get_version_via_com(p) for p in paths]))[0]
print(version)
# result: 80.0.3987.122
PS: I think people don't understand my question at the beginning and I'm sorry for my english
netifaces
module, because I played around with many tests in one file so I forgot to removed redundant module – Maximinamaximizegc_version = chromedriver_autoinstaller.get_chrome_version() print(gc_version)
– Irmgard