0

I am building a web scraping application using Selenium that will run on Windows desktops. I can assume the browser (Edge), but not the browser version (e.g. 90 or 91). I'm using JavaScript for ease of installation.

Before I instantiate Selenium, I need to determine the browser build (e.g. 90.0.818.46) so I can choose a compatible version of the WebDriver. I can use the amazing command line technique in how to get microsoft edge chromium version from command line or registry settings. However, I'd rather do this natively in JavaScript, ideally using the Windows Scripting Host interpreter. Node.js is also an option.

As described in the StackOverflow post mentioned above, in Python, I can query the registry directly. E.g.:

import winreg

keyPath1 = r"Software\Microsoft\Edge\BLBeacon"
key1 = winreg.OpenKey(winreg.HKEY_CURRENT_USER, keyPath1, 0, winreg.KEY_READ)
edgeVersion1 = winreg.QueryValueEx(key1, "version")[0]

Is there an equivalent approach in JavaScript?

I'm new to this so I'm open to other approaches to solve this use case.

mherzog
  • 1,085
  • 1
  • 12
  • 24
  • Maybe it can help: https://stackoverflow.com/questions/5916900/how-can-you-detect-the-version-of-a-browser – Michael Rovinsky Apr 25 '21 at 12:38
  • @Michael Rovinsky, this is helpful but if I understand correctly, all the solutions in the post you suggested assume the JavaScript is running in the browser -- i.e. that the ```navigator``` object is available. I want to determine the browser version before launching Selenium, so I can know what version of Selenium to use. – mherzog Apr 25 '21 at 12:43
  • 1
    I'm afraid it's impossible – Michael Rovinsky Apr 25 '21 at 12:51
  • *"I'd rather do this natively in JavaScript"* - What means "natively" to you? – IInspectable Apr 25 '21 at 15:48
  • @IInspectable By "natively", I mean without running an OS command and collecting the response. In the Python example I gave, the ```winreg``` package exposes the needed data without an explicit call to the OS. – mherzog Apr 25 '21 at 16:34

0 Answers0