0

Every time I run my python code, the Edge browser opens but does not load the URL. Then Windows system displays a dialog saying:

Microsoft Web Driver has stopped working.

A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available.

My Python code: (Running on PyCharm):

# Locate the web driver for Edge browser
driver = webdriver.Edge(executable_path = 'C:/Users/username/webdrivers/MicrosoftWebDriver.exe')

# Open the website
driver.get("https://google.com")

Warning/Error Message from PyCharm:

Traceback (most recent call last): File "02042020.py", line 14, in driver = webdriver.Edge(executable_path = 'C:/Users/username/webdrivers/MicrosoftWebDriver.exe') File "C:\Users\username\PycharmProjects\Web_Scraping\venv\lib\site-packages\selenium\webdriver\edge\webdriver.py", line 61, in init RemoteWebDriver.init( File "C:\Users\username\PycharmProjects\Web_Scraping\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in init self.start_session(capabilities, browser_profile) File "C:\Users\username\PycharmProjects\Web_Scraping\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "C:\Users\username\PycharmProjects\Web_Scraping\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 319, in execute response = self.command_executor.execute(driver_command, params) File "C:\Users\username\PycharmProjects\Web_Scraping\venv\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 374, in execute return self._request(command_info[0], url, body=data) File "C:\Users\username\PycharmProjects\Web_Scraping\venv\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 402, in _request resp = http.request(method, url, body=body, headers=headers) File "C:\Users\username\PycharmProjects\Web_Scraping\venv\lib\site-packages\urllib3\request.py", line 79, in request return self.request_encode_body( File "C:\Users\username\PycharmProjects\Web_Scraping\venv\lib\site-packages\urllib3\request.py", line 171, in request_encode_body return self.urlopen(method, url, **extra_kw) File "C:\Users\username\PycharmProjects\Web_Scraping\venv\lib\site-packages\urllib3\poolmanager.py", line 330, in urlopen response = conn.urlopen(method, u.request_uri, **kw) File "C:\Users\username\PycharmProjects\Web_Scraping\venv\lib\site-packages\urllib3\connectionpool.py", line 719, in urlopen retries = retries.increment( File "C:\Users\username\PycharmProjects\Web_Scraping\venv\lib\site-packages\urllib3\util\retry.py", line 400, in increment raise six.reraise(type(error), error, _stacktrace) File "C:\Users\username\PycharmProjects\Web_Scraping\venv\lib\site-packages\urllib3\packages\six.py", line 734, in reraise raise value.with_traceback(tb) File "C:\Users\username\PycharmProjects\Web_Scraping\venv\lib\site-packages\urllib3\connectionpool.py", line 665, in urlopen httplib_response = self._make_request( File "C:\Users\username\PycharmProjects\Web_Scraping\venv\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request six.raise_from(e, None) File "", line 3, in raise_from File "C:\Users\username\PycharmProjects\Web_Scraping\venv\lib\site-packages\urllib3\connectionpool.py", line 416, in _make_request httplib_response = conn.getresponse() File "C:\Users\username\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1322, in getresponse response.begin() File "C:\Users\username\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 303, in begin version, status, reason = self._read_status() File "C:\Users\username\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 264, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "C:\Users\username\AppData\Local\Programs\Python\Python38\lib\socket.py", line 669, in readinto return self._sock.recv_into(b)

urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

Environment details:

I tried troubleshooting but it didn't work.

My troubleshooting:

Enable Developer Mode which will install the appropriate version of WebDriver. On Windows:

Settings > Update & Security > For developers > select "Developer Mode".

Running CMD as administrator to install via DISM :

DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0

It says:

Deployment Image Servicing and Management tool
Version: 10.0.18362.1

Image Version: 10.0.18363.592

[==========================100.0%==========================]
The operation completed successfully.

I repeated these steps many times but it never worked. I downloaded web driver for Chrome and switched my Python code to run with Chrome browser and it worked. Unfortunately, the problem is that for this particular task, Microsoft Edge is the required browser. Can someone please advise? Thanks in advance!

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
an1que
  • 405
  • 3
  • 14

2 Answers2

2

Perhaps this issue occurs because you're using the Microsoft WebDriver version not matching the Microsoft Edge browser version. As far as I know, when we install the Microsoft Edge webdriver via DISM, by default, we could find the webdriver from the following folders:

"C:\\Windows\\SysWOW64\\MicrosoftWebDriver.exe"

and

"C:\\Windows\\System32\\MicrosoftWebDriver.exe",

You could check it and try to use this path in your code.

Zhi Lv
  • 18,845
  • 1
  • 19
  • 30
  • I replaced the path according to your suggestion and issue is resolved now. Thanks you very much. My up vote is not shown because I'm a new user on here. Your answer directly helps. – an1que Feb 06 '20 at 16:52
  • Congratulation. I suggest you to try to mark this answer as an accepted answer for this question after 48 hrs, when it is available to mark. It can help other community members in future in similar kind of issues. Thanks for your understanding. – Zhi Lv Feb 10 '20 at 10:06
-1

This error message...

urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

Microsoft Web Driver has stopped working.

A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available.

...implies that the MicrosoftWebDriver was unable to initiate/spawn a new WebBrowser i.e. Microsoft Edge Browser session.


Analysis

This error can occur due to numerous factors and some of the probhable causes and solutions are as follows:

  • You need to pass the absolute path of MicrosoftWebDriver through the key executable_path in either of the ways:

    • Within double quotes, escaping the back slashes:

      driver = webdriver.Edge(executable_path="C://Users//username//webdrivers//MicrosoftWebDriver.exe")
      
    • Within single quotes and front slashes, preceeded with the raw (r) switch:

      driver = webdriver.Edge(executable_path=r'C:\Users\username\webdrivers\MicrosoftWebDriver.exe')
      
  • This error is also observed when there is incompatibility between the version of the binaries you are using interms of Selenium client version, WebDriver variant version and Web Browser version. See Details.

  • You are using:
    • Edge web driver version: Release 17134 Version: 6.17134
    • Microsoft Edge version supported: 17.17134
    • Microsoft Edge Browser Version: Microsoft EdgeHTML 18.18363
  • As per Microsoft Edge Developer Guide:

EdgeHTML 18 includes the following new and updated features shipped in the current release of the Microsoft Edge platform, as of the Windows 10 October 2018 Update (10/2018, Build 17763). For changes in specific Windows Insider Preview builds, see the Microsoft Edge Changelog and What's New in EdgeHTML.


Solution

Ensure that:

  • Edge web driver version is upgraded to: Release 17763

Additional Steps

  • Enable Developer Mode which will install the appropriate version of WebDriver.

    Open Settings app > Go to Update & Security > For Developer and then select "Developer Mode".
    
  • You can also install a standalone version of WebDriver in one of two ways:

    • Search "Manage optional features" from Start, then select "Add a Feature", "WebDriver".
    • Install via DISM by running the following command in an elevated command prompt:

      DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0
      

Note: When installing MicrosoftWebDriver through the DISM command, by default the webdriver is installed within the following sub-directories:

  • 64 bit:

    C:\\Windows\\SysWOW64\\MicrosoftWebDriver.exe
    
  • 32 bit:

    C:\\Windows\\System32\\MicrosoftWebDriver.exe
    

References

You can find a couple of relevant discussions in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • "Ensure that: Edge web driver version is upgraded to: Release 17763" - Could you please elaborate how to upgrade the driver? The latest version found is Release 17134 (https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/) – an1que Feb 06 '20 at 00:03