-
-
Notifications
You must be signed in to change notification settings - Fork 460
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
Comments
@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.
|
I did some debugging on this. So basically, the
Here are the outputs on my machine: (1)
(2)
(3)
(4)
(5)
My Chrome versionMy
I have update logo at the top right corner of the Chrome window: Before clicking "Update", the version was What might be the problemThe first problem is that the path returned with That does not entirely explain why the returned Chrome version is
|
In addition to above, @aleksandr-kotlyar:
|
Summarizing previous, the
The 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 |
Now debugging inside the 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
So the problem seems to be that nothing is returned to |
I'm trying to run just the powershell script part. I copy-pasted the script contents, which are:
into a new script file, and ran it, and got:
Edit: Fixed for a copy-paste error in the powershell script (it had an extra newline that caused the error) |
While running this in powershell works:
..the same command does not produce desired output when using the 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. |
Thank you for such detailed research! |
Coming back to this. Probably it is a good idea to add the following flags to the
Then, I did some simple experiments using just When running in powershell, the following command works:
When running this in cmd, I got this:
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 (
|
Replacing single doublequotes with four doublequotes works, almost:
Now the problem is that for some reason the version is read from the
.. which does not work. It can be simplified even more:
which just prints the command back to the console. The problem seems to be the braces (
So apparently there should be special handling of quotes when they are enclosed in braces. |
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 |
Here is a powershell script I came up with that seems to do the job. First, the "all okay" case:
When I run this, I will get:
If there will be no match, it will print:
If one of the
and if everything fails, it will print:
as
it will find the first (and correct) version number in any of the cases. |
Actually, the values from the registry can also be read with powershell commands. This simplifies a possible implementation a bit. The following
will print just
Now it should be relatively straightforward to edit the |
@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 ;) |
@aleksandr-kotlyar for some reason the 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 |
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... Which leads to... self = <zipfile.ZipFile [closed]>
E zipfile.BadZipFile: File is not a zip file c:\python37\lib\zipfile.py:1289: BadZipFile On subsequent runs lead to this... 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. |
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
Run command prompt as admin |
@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. |
Steps to reproduce:
I tested with the
webdriver_manager
installed via pip (3.5.3) and the latest version from GitHub ( f7a0855 ).The text was updated successfully, but these errors were encountered: