SergeyPirogov / webdriver_manager

Apache License 2.0
2.05k stars 457 forks source link

Improperly retrieving OS browser version on Windows through Powershell #625

Open cmin764 opened 1 year ago

cmin764 commented 1 year ago

Under the _webdriver_manager/core/osmanager.py module we have the OperationSystemManager.get_browser_version_from_os method which employs the windows_browser_apps_to_cmd() utility to generate a Powershell script to be executed in order to run different local browser binary paths in order to output and detect the version.

From what I can tell, executing this directly in Powershell:

(Get-Item -Path "$env:PROGRAMFILES (x86)\Microsoft\Edge\Application\msedge.exe").VersionInfo.FileVersion

works, but taking that script and executing it with Popen as this shell liner: powershell "<code>" doesn't work, most probably because of the other " found inside the script, thus not expanding the $env:<name> properly.

I found a way to fix it on Robocorp side by enclosing the given path under single quotes ('), although this time it is known that var expansion won't work by design.


Of course, this is not a blocker, as the right version can be still retrieved from the registry approach, but would be good to find a way to run these Powershell scripts correctly from the library side in order to nicely be able to retrieve browser versions right from them. (aka fixing the quoted path passing to Get-Item while still supporting variable expansion during popen-based runs (or CMD runs))

SergeyPirogov commented 1 year ago

Need a PR