Azur DevOps抛出ValueError:无法使用以下命令获取Chrome的版本:reg查询

问题描述

代理池:Windows

已安装的Chrome版本:85.0.1483.102

当我运行Pytests时,它会抛出“ ValueError:无法使用以下命令获取Chrome的版本:reg查询“ HKEY_CURRENT_USER \ Software \ Google \ Chrome \ BLBeacon” / v版本”

Dev Ops已确认Windows代理具有Chrome。

我们被困在这里,无法前进。

有人可以把灯熄了吗!

在本地运行正常

2020-09-09T17:11:18.2185128Z ##[section]Starting: Run smoke_test copy
2020-09-09T17:11:18.2391733Z ==============================================================================
2020-09-09T17:11:18.2392103Z Task : Command line
2020-09-09T17:11:18.2392268Z Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
2020-09-09T17:11:18.2392446Z Version : 2.164.2
2020-09-09T17:11:18.2392574Z Author : Microsoft Corporation
2020-09-09T17:11:18.2392757Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
2020-09-09T17:11:18.2392882Z ==============================================================================
2020-09-09T17:11:19.3860400Z Generating script.
2020-09-09T17:11:19.4228320Z ========================== Starting Command Output ===========================
2020-09-09T17:11:19.4483483Z ##[command]"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "F:\XXX-vsts-agent-2_work_temp\f3ac2905-7c4a-40ef-a58b-c37a21431ffc.cmd""
2020-09-09T17:11:20.4105411Z Package Version
2020-09-09T17:11:20.4106029Z --------------------- ---------
2020-09-09T17:11:20.4106901Z ansi2html 1.5.2
2020-09-09T17:11:20.4108199Z apipkg 1.5
2020-09-09T17:11:20.4108775Z atomicwrites 1.4.0
2020-09-09T17:11:20.4110321Z attrs 20.2.0
2020-09-09T17:11:20.4110860Z certifi 2020.6.20
2020-09-09T17:11:20.4112407Z chardet 3.0.4
2020-09-09T17:11:20.4112925Z colorama 0.4.3
2020-09-09T17:11:20.4114389Z configparser 5.0.0
2020-09-09T17:11:20.4114959Z Crayons 0.4.0
2020-09-09T17:11:20.4116475Z docutils 0.16
2020-09-09T17:11:20.4116853Z execnet 1.7.1
2020-09-09T17:11:20.4118407Z htmlmin 0.1.12
2020-09-09T17:11:20.4118897Z idna 2.10
2020-09-09T17:11:20.4120404Z iniconfig 1.0.1
2020-09-09T17:11:20.4120942Z Jinja2 2.11.2
2020-09-09T17:11:20.4122443Z jsonschema 3.2.0
2020-09-09T17:11:20.4122990Z MarkupSafe 1.1.1
2020-09-09T17:11:20.4124497Z more-itertools 8.5.0
2020-09-09T17:11:20.4125054Z msgpack 1.0.0
2020-09-09T17:11:20.4126496Z numpy 1.19.1
2020-09-09T17:11:20.4127190Z packaging 20.4
2020-09-09T17:11:20.4128715Z pandas 1.1.2
2020-09-09T17:11:20.4129630Z pip 20.1.1
2020-09-09T17:11:20.4131451Z pluggy 0.13.1
2020-09-09T17:11:20.4132120Z py 1.9.0
2020-09-09T17:11:20.4132672Z pyparsing 2.4.7
2020-09-09T17:11:20.4133276Z pyrsistent 0.16.0
2020-09-09T17:11:20.4134242Z pytest 6.0.1
2020-09-09T17:11:20.4134770Z pytest-azurepipelines 0.8.0
2020-09-09T17:11:20.4160614Z pytest-colordots 1.1
2020-09-09T17:11:20.4161603Z pytest-forked 1.3.0
2020-09-09T17:11:20.4162070Z pytest-html 2.1.1
2020-09-09T17:11:20.4162463Z pytest-Metadata 1.10.0
2020-09-09T17:11:20.4162873Z pytest-ordering 0.6
2020-09-09T17:11:20.4163243Z pytest-reporter 0.4.0
2020-09-09T17:11:20.4163626Z pytest-reporter-html1 0.7.0
2020-09-09T17:11:20.4163994Z pytest-xdist 2.1.0
2020-09-09T17:11:20.4164382Z python-dateutil 2.8.1
2020-09-09T17:11:20.4164765Z python-json-config 1.2.3
2020-09-09T17:11:20.4165133Z pytz 2020.1
2020-09-09T17:11:20.4165634Z requests 2.24.0
2020-09-09T17:11:20.4166026Z selenium 3.141.0
2020-09-09T17:11:20.4166703Z setuptools 47.1.0
2020-09-09T17:11:20.4167116Z six 1.15.0
2020-09-09T17:11:20.4167546Z substring 0.2
2020-09-09T17:11:20.4167958Z toml 0.10.1
2020-09-09T17:11:20.4168388Z urllib3 1.25.10
2020-09-09T17:11:20.4169418Z webdriver-manager 3.2.2
2020-09-09T17:11:20.4750689Z WARNING: You are using pip version 20.1.1; however,version 20.2.3 is available.
2020-09-09T17:11:20.4751236Z You should consider upgrading via the 'c:\program files (x86)\python38-32\python.exe -m pip install --upgrade pip' command.
2020-09-09T17:11:22.3209924Z ============================= test session starts =============================
2020-09-09T17:11:22.3212494Z platform win32 -- Python 3.8.5,pytest-6.0.1,py-1.9.0,pluggy-0.13.1
2020-09-09T17:11:22.3361227Z rootdir: F:\xxxx-vsts-agent-2_work\18\s\Tests,configfile: pytest.ini
2020-09-09T17:11:22.3361685Z plugins: azurepipelines-0.8.0,colordots-1.1,forked-1.3.0,html-2.1.1,Metadata-1.10.0,ordering-0.6,reporter-0.4.0,reporter-html1-0.7.0,xdist-2.1.0
2020-09-09T17:11:22.3415903Z gw0 I / gw1 I / gw2 I / gw3 I / gw4 I
2020-09-09T17:11:25.4888327Z collected 7 items / 1 deselected / 6 selected
2020-09-09T17:11:27.7173269Z gw0 [6] / gw1 [6] / gw2 [6] / gw3 [6] / gw4 [6]
2020-09-09T17:11:27.7173855Z
2020-09-09T17:11:29.9637114Z ##[error]12 test(s) Failed,6 test(s) collected.
2020-09-09T17:11:29.9644764Z Skipping uploading of coverage data.
2020-09-09T17:11:29.9645049Z
2020-09-09T17:11:29.9648336Z =================================== ERRORS ====================================
2020-09-09T17:11:29.9654309Z _ ERROR at setup of Test_PayrollAccountant.test_Employee_TC_For_Regular_Week_Wit_Allowance_Rejected_By_PA _
2020-09-09T17:11:29.9654900Z [gw4] win32 -- Python 3.8.5 c:\program files (x86)\python38-32\python.exe
2020-09-09T17:11:29.9655182Z
2020-09-09T17:11:29.9655477Z request = <SubRequest 'setup' for >
2020-09-09T17:11:29.9655716Z
2020-09-09T17:11:29.9655953Z @pytest.fixture()
2020-09-09T17:11:29.9656193Z def setup(request):
2020-09-09T17:11:29.9656433Z url = str(ReadConfig.getApplicationURL())
2020-09-09T17:11:29.9656691Z Definedbrowser = ReadConfig.getbrowser()
2020-09-09T17:11:29.9656959Z global driver
2020-09-09T17:11:29.9657198Z if Definedbrowser.lower() == "chrome":
2020-09-09T17:11:29.9657458Z # driver=webdriver.Chrome("./Configurations/browser_Drivers/chromedriver.exe")
2020-09-09T17:11:29.9657729Z > driver = webdriver.Chrome(ChromeDriverManager().install())
2020-09-09T17:11:29.9657951Z
2020-09-09T17:11:29.9658196Z Tests\conftest.py:20:
2020-09-09T17:11:29.9658445Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2020-09-09T17:11:29.9658728Z C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Python\python38\site-packages\webdriver_manager\chrome.py:23: in init
2020-09-09T17:11:29.9659005Z self.driver = ChromeDriver(name=name,2020-09-09T17:11:29.9659263Z C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Python\python38\site-packages\webdriver_manager\driver.py:54: in init
2020-09-09T17:11:29.9659536Z self.browser_version = chrome_version(chrome_type)
2020-09-09T17:11:29.9659799Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2020-09-09T17:11:29.9660034Z
2020-09-09T17:11:29.9660260Z browser_type = 'google-chrome'
2020-09-09T17:11:29.9660484Z
2020-09-09T17:11:29.9660725Z def chrome_version(browser_type=ChromeType.GOOGLE):
2020-09-09T17:11:29.9660964Z pattern = r'\d+.\d+.\d+'
2020-09-09T17:11:29.9661276Z
2020-09-09T17:11:29.9661529Z cmd_mapping = {
2020-09-09T17:11:29.9661779Z ChromeType.GOOGLE: {
**2020-09-09T17:11:29.9662026Z OSType.LINUX: 'google-chrome --version || google-chrome-stable --version',2020-09-09T17:11:29.9662302Z OSType.MAC: r'/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version',2020-09-09T17:11:29.9662579Z OSType.WIN: r'reg query "HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon" /v version'**
2020-09-09T17:11:29.9662827Z },2020-09-09T17:11:29.9663073Z ChromeType.CHROMIUM: {
2020-09-09T17:11:29.9663797Z OSType.LINUX: 'chromium --version || chromium-browser --version',2020-09-09T17:11:29.9664095Z OSType.MAC: r'/Applications/Chromium.app/Contents/MacOS/Chromium --version',2020-09-09T17:11:29.9665293Z OSType.WIN: r'reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome" /v version'
2020-09-09T17:11:29.9665603Z },2020-09-09T17:11:29.9665849Z ChromeType.MSEDGE: {
2020-09-09T17:11:29.9666118Z OSType.MAC: r'/Applications/Microsoft\ Edge.app/Contents/MacOS/Microsoft\ Edge --version',2020-09-09T17:11:29.9666392Z OSType.WIN: r'reg query "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Edge\BLBeacon" /v version',2020-09-09T17:11:29.9666646Z }
2020-09-09T17:11:29.9666886Z }
2020-09-09T17:11:29.9667218Z
2020-09-09T17:11:29.9667449Z cmd = cmd_mapping[browser_type][os_name()]
2020-09-09T17:11:29.9667680Z stdout = os.popen(cmd).read()
2020-09-09T17:11:29.9667924Z version = re.search(pattern,stdout)
2020-09-09T17:11:29.9668150Z if not version:
**2020-09-09T17:11:29.9668391Z > raise ValueError(f'Could not get version for Chrome with this command: {cmd}')
2020-09-09T17:11:29.9668658Z E ValueError: Could not get version for Chrome with this command: reg query "HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon" /v version**
2020-09-09T17:11:29.9668917Z
2020-09-09T17:11:29.9669153Z C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Python\python38\site-packages\webdriver_manager\utils.py:142: ValueError

请查看以下屏幕截图

enter image description here

enter image description here

enter image description here

enter image description here

解决方法

日志显示ERROR: The system was unable to find the specified registry key or value.,当您通过服务在托管代理上运行时,我认为HKEY_CURRENT_USER无效。您可以尝试使用以下命令获取exe文件的version属性:

(Get-Item "C:\Program Files\Google\Chrome\Application\chrome.exe").VersionInfo

enter image description here