Home > database >  How do I determine which MS Edge Driver is compatible with my OS Version to enable web automation wi
How do I determine which MS Edge Driver is compatible with my OS Version to enable web automation wi

Time:08-07

I've been using Selenium with the Edge Driver for some time. I've been instantiating my Edge Driver by specifying the executable_path= parameter with no issues. However, I recently switched my web automation project to use the webdriver_manager, i.e., webdriver_manager.microsoft import EdgeChromiumDriverManager. Now, when I command the driver to navigate to any webpage - it opens for one second, then immediately closes. The current troubleshooting step I'm on is ensuring that the Edge Driver I'm using (the one downloaded by using the webdriver_manager module) is compatible with my current OS Version, but now I'm stumped. I don't know how to find which MS Edge Driver is compatible/correct for my current OS build - I see no patterns when comparing the two, e.g.:

My current OS:

enter image description here

The webdriver downloaded by the webdriver_manager:

enter image description here

And here is a link to all MS Edge Drivers:

https://msedgewebdriverstorage.z22.web.core.windows.net/

So, how do I find the Edge Driver that is "right" for my OS? When I look at these two numbers: OS build - 22000.795 and Edge webdriver version - 103.0.1264.77; I see no pattern or way of determining which driver is compatible. Maybe, I'm using the webdriver_manager module improperly? I know I can use the executable path, but I'm under the impression that using the webriver_manager automates the install of new releases for you so you don't have to update your script to new edge drivers in the future.

For additional context, here is my code (using Facebook's domain just as an example):

from selenium import webdriver
from selenium.webdriver.edge.service import Service as EdgeService
from webdriver_manager.microsoft import EdgeChromiumDriverManager

driver = webdriver.Edge(service = EdgeService(EdgeChromiumDriverManager().install()))

driver.get('https://facebook.com')

CodePudding user response:

The SeleniumBase driver manager works well with Edge:

from seleniumbase import get_driver

driver = get_driver("edge", headless=False)
driver.get("https://facebook.com")
import time; time.sleep(1)
driver.quit()

(Here's another example using the raw driver manager: raw_browser_launcher.py)

Alternatively, you can use the more simple format with automatic setUp and tearDown, but then you need to run your test with pytest and add --edge as a command-line option to use Edge:

from seleniumbase import BaseCase

class MyTestClass(BaseCase):
    def test_facebook(self):
        self.open("https://facebook.com")
        self.sleep(1)
pytest test_facebook.py --edge
========================= test session starts ==========================
platform darwin -- Python 3.10.5, pytest-7.1.2, pluggy-1.0.0
rootdir: /Users/michael/github/SeleniumBase/examples, configfile: pytest.ini
plugins: html-2.0.1, xdist-2.5.0, forked-1.4.0, rerunfailures-10.2, ordering-0.6, cov-3.0.0, metadata-2.0.2, seleniumbase-3.5.11
collected 1 item                                                       

test_facebook.py .

========================== 1 passed in 4.40s ===========================

CodePudding user response:

It's working now (i.e., with the same code example in my original question, the MS Edge window now opens as commanded and remains open). I found the MS Docs regarding Edge webdriver installation/configuration

https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/?tabs=c-sharp

and here are the steps I followed:

  1. The first step is to ensure that your Edge webdriver ("msedgedriver.exe") version matches your Edge browser version (I read a tech blog that said my OS build version needed to match my "msedgedriver.exe" version - thinking maybe that's wrong now?)

  2. I navigated to About Microsoft Edge in settings: edge://settings/help

which displays my current MS Edge version - It was covered with a prompt to update Edge - so I did. Checked after update and my version was: 104.0.1293.47

  1. On a whim, suspecting that maybe my Edge browser update was the cause for webdriver_manager downloading the incompatible msedgedriver.exe, I attempted to run my script again (exact same one I posted in original question)

And it worked - I checked the msedgedriver.exe version right after and noticed that webdriver_manager downloaded a new version: 104.0.1293 - which matches my current Edge Browser version.

So, I'm not 100% sure what the cause for the webdriver_manager failing to download the correct version (to match my browser) was - but until I updated my MS Edge Browser, no new drivers were installed. Then after update and running the script, the right driver is installed and it's working fine now.

  • Related