Reputation: 11
I have to automate getting edge chromium browser version in python. I tried the registry settings mentioned in this HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge
.But that registry key is not present.
Upvotes: 1
Views: 9009
Reputation: 2492
You can retrieve Microsoft Edge Chromium version programmatically: from Windows Registry or Windows Management Instrumentation (WMI) Database
Let's start with command line versions:
Registry (Method 1)
reg.exe QUERY "HKEY_CURRENT_USER\Software\Microsoft\Edge\BLBeacon" /t REG_SZ /reg:32 /v version
Registry (Method 2)
reg.exe QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" /t REG_SZ /reg:32 /v pv
WMI (Method 3)
wmic.exe DATAFILE WHERE "NAME='C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe'" GET Version /value
Here's a simple Python script for retrieving the version from Registry (using winreg
module) and WMI (by calling wmic.exe
and parsing its output)
import subprocess import winreg import re # ----- Method 1 ----- keyPath1 = r"Software\Microsoft\Edge\BLBeacon" key1 = winreg.OpenKey(winreg.HKEY_CURRENT_USER, keyPath1, 0, winreg.KEY_READ) edgeVersion1 = winreg.QueryValueEx(key1, "version")[0] print(f'Method #1 >>> {edgeVersion1}') # ----- Method 2 ----- keyPath2 = r"SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" key2 = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, keyPath2, 0, winreg.KEY_READ) edgeVersion2 = winreg.QueryValueEx(key2, "pv")[0] print(f'Method #2 >>> {edgeVersion1}') # ----- Method 3 ----- msedgeExe = r"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe" cmdArgs = ["wmic", "DATAFILE", "WHERE", r"NAME='{0}'".format(msedgeExe), "GET", "Version", "/value"] process = subprocess.check_output(cmdArgs) edgeVersion3 = re.sub("Version=", "", process.strip().decode()) print(f'Method #3 >>> {edgeVersion3}')
Tested with Python 3.8.2 on Windows 10 Version 1909
Hope that helps!
Upvotes: 5
Reputation: 21656
I have to automate getting edge chromium browser version in python.
Do you mean you want to use selenium Edge webdriver to do the automate test? If that is the case, you could refer to this article to download the correct Microsoft WebDriver version for your build of Microsoft Edge, and download a WebDriver language binding of your choice.
Then, use the driver.capabilities['browserVersion']
command to get the Microsoft Edge Chromium version in python, more detail, please check the following code (remember to change the path to yours):
import time
from selenium import webdriver
from selenium.webdriver.edge.options import Options
print("*******************")
option = Options()
option.set_capability("useAutomationExtension", "false")
option.binary_location = "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"
driver = webdriver.Edge(executable_path=r'E:\webdriver\edgedriver_win64_81_0_416_72\edgedriver_win64\msedgedriver.exe', capabilities= option.to_capabilities());
print(driver.capabilities['browserVersion'])
driver.get("https://www.bing.com")
time.sleep(5)
print("*******************")
time.sleep(5)
The output:
Besides, here is another method to use Command Line to get the Edge chromium version, might be it can help you.
You could use the following command to get the Microsoft Edge Chromium Version:
For Microsoft Edge Stable version (using the default setting):
wmic datafile where name="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe" get Version /value
For the Microsoft Edge Dev or Beta version, change the path to yours:
wmic datafile where name="C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe" get Version /value
The screenshot as below:
Upvotes: 0