Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

google-chrome version is UNKNOWN with webdriver_manager 3.5.3 (Win) #307

Closed
fohrloop opened this issue Feb 17, 2022 · 18 comments · Fixed by #310
Closed

google-chrome version is UNKNOWN with webdriver_manager 3.5.3 (Win) #307

fohrloop opened this issue Feb 17, 2022 · 18 comments · Fixed by #310

Comments

@fohrloop
Copy link
Contributor

Steps to reproduce:

In [1]: import webdriver_manager

In [2]: webdriver_manager.__version__
Out[2]: '3.5.3'

In [3]: from webdriver_manager.utils import *

In [4]: get_browser_version_from_os("google-chrome")
[WDM] - Could not get version for google-chrome with the command:  powershell "$ErrorActionPreference='silentlycontinue' ; (Get-Item -Path "$env:PROGRAMFILES\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion ; if (-not $? -or $? -match $error) { (Get-Item -Path "$env:PROGRAMFILES(x86)\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion 
} if (-not $? -or $? -match $error) { (Get-Item -Path "$env:LOCALAPPDATA\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion } if (-not $? -or $? -match $error) { reg query "HKCU\SOFTWARE\Google\Chrome\BLBeacon" /v version } if (-not $? -or $? -match $error) { reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome" /v version }"
[WDM] - Current google-chrome version is UNKNOWN
Out[4]: 'UNKNOWN'

I tested with the webdriver_manager installed via pip (3.5.3) and the latest version from GitHub ( f7a0855 ).

@aleksandr-kotlyar
Copy link
Collaborator

aleksandr-kotlyar commented Feb 17, 2022

@np-8 thank you for your report! It's very interesting because I've tried to find all the ways to determine google chrome on windows and I have made a lot of tests. Please add some additional info which will help to find a solution for your issue. Please give answers to these questions to let us see the full picture.

  1. Whats your windows version and architecture (32/64)?
  2. What configuration - local computer, docker, virtual machine, cloud, something else?
  3. Has powershell?
  4. What is the version of powershell?
  5. Does google chrome installed?
  6. How google chrome has been installed?
  7. What location of google-chrome on the disc?
  8. PATH variable has google chrome binary path?
  9. What's the PATH to Google Chrome?
  10. Bonus: if you can find register which contains installed google chrome version to share with us - this will help a lot to resolve your issue.

@fohrloop
Copy link
Contributor Author

I did some debugging on this. So basically, the chrome.exe filepath is searched with the following ways:

(1)
(Get-Item -Path "$env:PROGRAMFILES\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion

(2)
(Get-Item -Path "$env:PROGRAMFILES(x86)\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion

(3)
(Get-Item -Path "$env:LOCALAPPDATA\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion

(4)
reg query "HKCU\SOFTWARE\Google\Chrome\BLBeacon" /v version

(5)
reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome" /v version

Here are the outputs on my machine:

(1)

PS C:\Users\niko> (Get-Item -Path "$env:PROGRAMFILES\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion
Get-Item : Cannot find path 'C:\Program Files\Google\Chrome\Application\chrome.exe' because it does not exist.
At line:1 char:2
+ (Get-Item -Path "$env:PROGRAMFILES\Google\Chrome\Application\chrome.e ...
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (C:\Program Files\Go\u2026lication\chrome.exe:String) [Get-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand

(2)

PS C:\Users\niko> (Get-Item -Path "$env:PROGRAMFILES(x86)\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion

Get-Item : Cannot find path 'C:\Program Files(x86)\Google\Chrome\Application\chrome.exe' because it does not exist.
At line:1 char:2
+ (Get-Item -Path "$env:PROGRAMFILES(x86)\Google\Chrome\Application\chr ...
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (C:\Program Files(x8\u2026lication\chrome.exe:String) [Get-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand

(3)

PS C:\Users\niko> (Get-Item -Path "$env:LOCALAPPDATA\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion
Get-Item : Cannot find path 'C:\Users\niko\AppData\Local\Google\Chrome\Application\chrome.exe' because it does not exist.
At line:1 char:2
+ (Get-Item -Path "$env:LOCALAPPDATA\Google\Chrome\Application\chrome.e ...
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (C:\Users\niko\AppDa\u2026lication\chrome.exe:String) [Get-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand

(4)

PS C:\Users\niko> reg query "HKCU\SOFTWARE\Google\Chrome\BLBeacon" /v version

HKEY_CURRENT_USER\SOFTWARE\Google\Chrome\BLBeacon
    version    REG_SZ    97.0.4692.99

(5)

PS C:\Users\niko> reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome" /v version

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome
    version    REG_SZ    98.0.4758.102

My Chrome version

My chrome.exe is located at: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe. Inside the C:\Program Files (x86)\Google\Chrome\Application\ folder I have actually

  • Folder called 97.0.4692.99
  • Folder called 98.0.4758.102
  • Executables chrome.exe and new_chrome.exe.

I have update logo at the top right corner of the Chrome window:

image

Before clicking "Update", the version was 97.0.4692.99, and after clicking update is was 98.0.4758.102. After clicking the update button the folder 97.0.4692.99 and new_chrome.exe were removed from C:\Program Files (x86)\Google\Chrome\Application\chrome.exe. So this explains why the two reg query commands gave different chrome versions; the Chrome update was process was unfinished. Still after the Chrome update, the get_browser_version_from_os("google-chrome") returns 'UNKNOWN'.

What might be the problem

The first problem is that the path returned with (2) is actually 'C:\Program Files(x86)\Google\Chrome\Application\chrome.exe' which is missing the space just before (x86)!

That does not entirely explain why the returned Chrome version is 'UNKNOWN' as both of the reg query commands give after the finished Chrome update the same version:

PS C:\Users\niko> reg query "HKCU\SOFTWARE\Google\Chrome\BLBeacon" /v version

HKEY_CURRENT_USER\SOFTWARE\Google\Chrome\BLBeacon
    version    REG_SZ    98.0.4758.102

PS C:\Users\niko> reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome" /v version

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome
    version    REG_SZ    98.0.4758.102
```

@fohrloop
Copy link
Contributor Author

In addition to above, @aleksandr-kotlyar:

  1. Windows 10 64-bit, Version 21H2, Build 19044.1466
  2. Local computer
  3. Yes
  4. I have multiple versions of powershell installed. If I start powershell from cmd, I can see this:
PS C:\Users\niko> (Get-Host).Version

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      19041  1320
  1. Yes
  2. Downloaded with Edge, probably
  3. See previous comment
  4. No
  5. -
  6. See previous comment

@fohrloop
Copy link
Contributor Author

fohrloop commented Feb 17, 2022

Summarizing previous, the (2) after fixing the missing space (and completing the update), gives:

PS C:\Users\niko> (Get-Item -Path "$env:PROGRAMFILES (x86)\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion
98.0.4758.102

The (4) is all the times more reliable than (5) as it really gave the current version of chrome, even if there is update process going on. When I was in midst of the update process, and trying to use some dash testing scripts, which use selenium, I got:

  File "C:\somevenvpath\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 98
Current browser version is 97.0.4692.99 with binary path C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

Note that (2) and (4) give the version in different formats.

@fohrloop
Copy link
Contributor Author

Now debugging inside the webdriver_manager\utils.py:read_version_from_cmd.

def read_version_from_cmd(cmd, pattern):
    with subprocess.Popen(
        cmd,
        stdout=subprocess.PIPE,
        stderr=subprocess.DEVNULL,
        stdin=subprocess.DEVNULL,
        shell=True,
    ) as stream:
        stdout = stream.communicate()[0].decode()
        version = re.search(pattern, stdout)

    breakpoint()
    return version

The cmd and stdout are:

In [3]: cmd
Out[3]: ' powershell "$ErrorActionPreference=\'silentlycontinue\' ; (Get-Item -Path "$env:PROGRAMFILES\\Google\\Chrome\\Application\\chrome.exe").VersionInfo.FileVersion ; if (-not $? -or $? -match $error) { (Get-Item -Path "$env:PROGRAMFILES(x86)\\Google\\Chrome\\Application\\chrome.exe").VersionInfo.FileVersion } if (-not $? -or $? -match $error) { (Get-Item -Path "$env:LOCALAPPDATA\\Google\\Chrome\\Application\\chrome.exe").VersionInfo.FileVersion } if (-not $? -or $? -match $error) { reg query "HKCU\\SOFTWARE\\Google\\Chrome\\BLBeacon" /v version } if (-not $? -or $? -match $error) { reg query "HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Google Chrome" /v version }"'

In [4]: stdout
Out[4]: ''

So the problem seems to be that nothing is returned to stdout.

@fohrloop
Copy link
Contributor Author

fohrloop commented Feb 17, 2022

I'm trying to run just the powershell script part. I copy-pasted the script contents, which are:

$ErrorActionPreference='silentlycontinue' ; (Get-Item -Path "$env:PROGRAMFILES\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion ; if (-not $? -or $? -match $error) { (Get-Item -Path "$env:PROGRAMFILES(x86)\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion } if (-not $? -or $? -match $error) { (Get-Item -Path "$env:LOCALAPPDATA\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion } if (-not $? -or $? -match $error) { reg query "HKCU\SOFTWARE\Google\Chrome\BLBeacon" /v version } if (-not $? -or $? -match $error) { reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome" /v version }

into a new script file, and ran it, and got:

PS C:\Users\niko> powershell -File C:\tmp\testscript.ps1

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome
    version    REG_SZ    98.0.4758.102

Edit: Fixed for a copy-paste error in the powershell script (it had an extra newline that caused the error)

@fohrloop
Copy link
Contributor Author

fohrloop commented Feb 17, 2022

While running this in powershell works:

PS C:\Users\niko> (Get-Item -Path "$env:PROGRAMFILES (x86)\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion
98.0.4758.102

..the same command does not produce desired output when using the communicate():

In [44]: cmd = r""" powershell "$ErrorActionPreference='silentlycontinue' ; (Get-Item -Path "$env:PROGRAMFILES (x86)\Google\Chrome\Application\chrome.exe").VersionInfo.FileVer 
    ...: sion ;"""

In [45]: with subprocess.Popen(
    ...:     cmd,
    ...:     stdout=subprocess.PIPE,
    ...:     stderr=subprocess.DEVNULL,
    ...:     stdin=subprocess.DEVNULL,
    ...:     shell=True,
    ...: ) as stream:
    ...:     print(stream.communicate())
(b'', None)

I'm trying make a minimal example that will return the output from the powershell to python.

@aleksandr-kotlyar
Copy link
Collaborator

Thank you for such detailed research!
Yeah, seams that there is missing space for env with PROGRAMFILES (x86)
You can make a PR if you want or I can do it this evening.

@fohrloop
Copy link
Contributor Author

Coming back to this. Probably it is a good idea to add the following flags to the powershell command:

-ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -Command

Then, I did some simple experiments using just cmd.

When running in powershell, the following command works:

PS C:\Users\niko>  (Get-Item -Path "$env:PROGRAMFILES (x86)\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion
98.0.4758.102

When running this in cmd, I got this:

C:\Users\niko> powershell  -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -Command  "(Get-Item -Path "$env:PROGRAMFILES (x86)\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion"
x86 : The term 'x86' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:36
+ (Get-Item -Path $env:PROGRAMFILES (x86)\Google\Chrome\Application\chr ...
+                                    ~~~
    + CategoryInfo          : ObjectNotFound: (x86:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

you might already guessed from this that the problem has something to do with quoting. Reading from here I guessed that I should add the number of quotes in the subexpression. So, using four doublequotes ("""") instead of a single doublequote (") will work:

C:\Users\niko> powershell  -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -Command  "(Get-Item -Path """"$env:PROGRAMFILES (x86)\Google\Chrome\Application\chrome.exe"""").VersionInfo.FileVersion"
98.0.4758.102

@fohrloop
Copy link
Contributor Author

Replacing single doublequotes with four doublequotes works, almost:

C:\Users\niko> powershell -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -Command "$ErrorActionPreference='silentlycontinue' ; (Get-Item -Path """"$env:PROGRAMFILES\Google\Chrome\Application\chrome.exe"""").VersionInfo.FileVersion ; if (-not $? -or $? -match $error) { (Get-Item -Path """"$env:PROGRAMFILES (x86)\Google\Chrome\Application\chrome.exe"""").VersionInfo.FileVersion } if (-not $? -or $? -match $error) { (Get-Item -Path """"$env:LOCALAPPDATA\Google\Chrome\Application\chrome.exe"""").VersionInfo.FileVersion } if (-not $? -or $? -match $error) { reg query """"HKCU\SOFTWARE\Google\Chrome\BLBeacon"""" /v version } if (-not $? -or $? -match $error) { reg query """"HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome"""" /v version }"

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome
    version    REG_SZ    98.0.4758.102

Now the problem is that for some reason the version is read from the req query command and not from the previous working command using the Get-Item. Simplifying the command above gives:

C:\Users\niko>powershell -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -Command "$ErrorActionPreference='silentlycontinue' ; (Get-Item -Path """"$env:PROGRAMFILES\Google\Chrome\Application\chrome.exe"""").VersionInfo.FileVersion ; if (-not $? -or $? -match $error) { (Get-Item -Path """"$env:PROGRAMFILES (x86)\Google\Chrome\Application\chrome.exe"""").VersionInfo.FileVersion }"

.. which does not work. It can be simplified even more:

C:\Users\niko>powershell -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -Command "{ (Get-Item -Path """"$env:PROGRAMFILES (x86)\Google\Chrome\Application\chrome.exe"""").VersionInfo.FileVersion }"
 (Get-Item -Path "$env:PROGRAMFILES (x86)\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion

which just prints the command back to the console. The problem seems to be the braces ({}). When you remove the braces, you'll see:

C:\Users\niko>powershell -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -Command "(Get-Item -Path """"$env:PROGRAMFILES (x86)\Google\Chrome\Application\chrome.exe"""").VersionInfo.FileVersion"
98.0.4758.102

So apparently there should be special handling of quotes when they are enclosed in braces.

@fohrloop
Copy link
Contributor Author

I have a feeling that it might be difficult trying to get command passed from cmd to Powershell in every situation as is. From this answer it looks like the -EncodedCommand might be the way to go.

@fohrloop
Copy link
Contributor Author

Here is a powershell script I came up with that seems to do the job. First, the "all okay" case:

$ErrorActionPreference='silentlycontinue'

$chromepathending = "\Google\Chrome\Application\chrome.exe"
$chromepath = Get-Item -Path (Join-Path ${env:ProgramFiles} -ChildPath $chromepathending)

if (-not (Test-Path -Path $chromepath))
{
	$chromepath = Get-Item -Path (Join-Path ${env:ProgramFiles(x86)} -ChildPath $chromepathending)
}
if (-not (Test-Path -Path $chromepath))
{
	$chromepath = Get-Item -Path (Join-Path ${env:LOCALAPPDATA} -ChildPath $chromepathending)
}

if ((Test-Path -Path $chromepath))
{
	echo $chromepath.VersionInfo.FileVersion
} else {
	reg query "HKCU\SOFTWARE\Google\Chrome\BLBeacon" /v version
	reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome" /v version
} 

When I run this, I will get:

PS C:\Users\niko> & C:\tmp\testscript.ps1
98.0.4758.102

If there will be no match, it will print:

PS C:\Users\niko> & C:\tmp\testscript.ps1

HKEY_CURRENT_USER\SOFTWARE\Google\Chrome\BLBeacon
    version    REG_SZ    98.0.4758.102


HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome
    version    REG_SZ    98.0.4758.102

If one of the reg query's will not work, it will print:

PS C:\Users\niko> & C:\tmp\testscript.ps1
ERROR: The system was unable to find the specified registry key or value.

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome
    version    REG_SZ    98.0.4758.102

and if everything fails, it will print:

PS C:\Users\niko> & C:\tmp\testscript.ps1
ERROR: The system was unable to find the specified registry key or value.
ERROR: The system was unable to find the specified registry key or value.
```.

This output string is then parsed in `webdriver_manager\utils.py:read_version_from_cmd`:

```python
        stdout = stream.communicate()[0].decode()
        version = re.search(pattern, stdout)

as pattern is

In [7]: pattern
Out[7]: '\\d+\\.\\d+\\.\\d+'

it will find the first (and correct) version number in any of the cases.

@fohrloop
Copy link
Contributor Author

Actually, the values from the registry can also be read with powershell commands. This simplifies a possible implementation a bit. The following

$ErrorActionPreference='silentlycontinue'

(Get-Item -Path (Join-Path ${env:ProgramFiles} -ChildPath "\Google\Chrome\Application\chrome.exe")).VersionInfo.FileVersion
(Get-Item -Path (Join-Path ${env:ProgramFiles(x86)} -ChildPath "\Google\Chrome\Application\chrome.exe")).VersionInfo.FileVersion
(Get-Item -Path (Join-Path ${env:LOCALAPPDATA} -ChildPath "\Google\Chrome\Application\chrome.exe")).VersionInfo.FileVersion
(Get-ItemProperty -Path Registry::HKCU\SOFTWARE\Google\Chrome\BLBeacon).version
(Get-ItemProperty -Path Registry::"HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome").version

will print just

PS C:\Users\niko> & C:\tmp\testscript.ps1
98.0.4758.102
98.0.4758.102
98.0.4758.102

Now it should be relatively straightforward to edit the windows_browser_apps_to_cmd a bit to check a list of commands that return a value and stop on the first hit.

@aleksandr-kotlyar
Copy link
Collaborator

@np-8 that's how windows_browser_apps_to_cmd works now. It stops on first result which is not $ERROR. So need just to correct list of commands, not algorithm ;)

fohrloop pushed a commit to fohrloop/webdriver_manager that referenced this issue Feb 17, 2022
@fohrloop
Copy link
Contributor Author

@aleksandr-kotlyar for some reason the windows_browser_apps_to_cmd did not work. As a reference, here is a branch without changes in windows_browser_apps_to_cmd. The output with that branch is the same as with when using a8f64d2:

In [1]: from webdriver_manager.utils import *

In [2]: get_browser_version_from_os("google-chrome")
[WDM] - Could not get version for google-chrome with the command:  powershell "$ErrorActionPreference='silentlycontinue' ; (Get-Item -Path "$env:PROGRAMFILES\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion ; if (-not $? -or $? -match $error) { (Get-Item -Path "$env:PROGRAMFILES(x86)\Google\Chrome\AppVersionInfo.FileVersion } if (-not $? -or $? -match $error) { (Get-ItemProperty -Path Registry::HKCU\SOFTWARE\Google\Chrome\BLBeacon).version } if (-not $? -or $? -match $error) { (Get-ItemProperty -Path Registry::"HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome").version }"      
[WDM] - Current google-chrome version is UNKNOWN
Out[2]: 'UNKNOWN'

PS. There was actually no problem in the $env:PROGRAMFILES(x86); it should be like that.

@GonadiusPrime
Copy link

Same results on Windows Server 2016. As a result of this, I believe it is going and pulling the latest driver, even though it exists locally. This combined with xdist, I suspect, is making all the Jenkins runs fail.

First this...
INFO WDM:logger.py:26 ====== WebDriver manager ======
INFO WDM:logger.py:26 Could not get version for google-chrome with the command: powershell "$ErrorActionPreference='silentlycontinue' ; (Get-Item -Path "$env:PROGRAMFILES\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion ; if (-not $? -or $? -match $error) { (Get-Item -Path "$env:PROGRAMFILES(x86)\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion } if (-not $? -or $? -match $error) { (Get-Item -Path "$env:LOCALAPPDATA\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion } if (-not $? -or $? -match $error) { reg query "HKCU\SOFTWARE\Google\Chrome\BLBeacon" /v version } if (-not $? -or $? -match $error) { reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome" /v version }"
INFO WDM:logger.py:26 Current google-chrome version is UNKNOWN
INFO WDM:logger.py:26 Get LATEST chromedriver version for UNKNOWN google-chrome
INFO WDM:logger.py:26 Trying to download new driver from https://chromedriver.storage.googleapis.com/98.0.4758.102/chromedriver_win32.zip

Which leads to...
c:\python37\lib\site-packages\webdriver_manager\chrome.py:32: in install
driver_path = self._get_driver_path(self.driver)
c:\python37\lib\site-packages\webdriver_manager\manager.py:32: in _get_driver_path
driver_name, os_type, driver_version)
c:\python37\lib\site-packages\webdriver_manager\driver_cache.py:28: in save_file_to_cache
files = archive.unpack(path)
c:\python37\lib\site-packages\webdriver_manager\archive.py:30: in unpack
return self.__extract_zip(directory)
c:\python37\lib\site-packages\webdriver_manager\archive.py:36: in __extract_zip
archive = zip_class(self.file_path)
c:\python37\lib\zipfile.py:1222: in init
self._RealGetContents()


self = <zipfile.ZipFile [closed]>

def _RealGetContents(self):
    """Read in the table of contents for the ZIP file."""
    fp = self.fp
    try:
        endrec = _EndRecData(fp)
    except OSError:
        raise BadZipFile("File is not a zip file")
    if not endrec:
      raise BadZipFile("File is not a zip file")

E zipfile.BadZipFile: File is not a zip file

c:\python37\lib\zipfile.py:1289: BadZipFile

On subsequent runs lead to this...
[WDM] - ====== WebDriver manager ======
[WDM] - Current google-chrome version is 98.0.4758
[WDM] - Get LATEST driver version for 98.0.4758
[WDM] - There is no [win32] chromedriver for browser 98.0.4758 in cache
[WDM] - Get LATEST driver version for 98.0.4758
[WDM] - Trying to download new driver from https://chromedriver.storage.googleapis.com/98.0.4758.102/chromedriver_win32.zip
[WDM] - Driver has been saved in cache [C:\Users\Jenkins.wdm\drivers\chromedriver\win32\98.0.4758.102]

selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home

subprocess.py - PermissionError: [WinError 32] The process cannot access the file because it is being used by another process

Or it may be completely unrelated. I know the webdriver is capable of working, in a single instance, just not multiple. Roughly the same results with MSEdge.

@geojitsu
Copy link

It does appear webdriver is looking in c:\Program Files, and not where google installs by default -- C:\Program Files (x86)

Simple solution, just create a link to chrome between the two directories

  1. Create the folder structure C:\Program Files\Google\Chrome
  2. Link the "Application" subdirectory to c:\Program Files (x86)\Google\Chrome\Application (see below)
  3. Profit

Run command prompt as admin
mkdir "C:\Program Files\Google\Chrome"
mklink /J "c:\Program Files\Google\Chrome\Application" "c:\Program Files (x86)\Google\Chrome\Application"

@aleksandr-kotlyar
Copy link
Collaborator

It does appear webdriver is looking in c:\Program Files, and not where google installs by default -- C:\Program Files (x86)

Simple solution, just create a link to chrome between the two directories

  1. Create the folder structure C:\Program Files\Google\Chrome
  2. Link the "Application" subdirectory to c:\Program Files (x86)\Google\Chrome\Application (see below)
  3. Profit

Run command prompt as admin mkdir "C:\Program Files\Google\Chrome" mklink /J "c:\Program Files\Google\Chrome\Application" "c:\Program Files (x86)\Google\Chrome\Application"

@geojitsu webdriver-manager is already looking in both places

$env:PROGRAMFILES (x86)\Google\Chrome\Application\chrome.exe
$env:PROGRAMFILES\Google\Chrome\Application\chrome.exe

what version of webdriver-manager do you use? If it appears on the latest versions of webdriver-manager - please create new issue if it reproduces and link to this issue. Cause this issue is closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants