An unhandled exception of type SeleniumWebDriverException occurred in WebDriverdll A exception with a null response was thrown using EdgeDriver

0

I am using Selenium in C# with the Edge driver however when I run the code I receive the following error. Using OpenQA.Selenium; using OpenQA.Selenium.Edge;

class HomePageTests
{
    static void Main(string[] args)
    {
        {
            {
                IWebDriver AzimaHome = new EdgeDriver();
                AzimaHome.Navigate().GoToUrl("http:www.msn.com");

                IList<IWebElement> terms = AzimaHome.FindElements(By.TagName("a"));
                terms.First(element => element.Text == "").Click();
            }
        }
    }
}

Exception thrown:

OpenQA SeleniumWebDriverException' in WebDriver.dll
An unhandled exception of type SeleniumWebDriverException' occurred in WebDriverdll
A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:52586/session. The status of the exception was Receive Failure, and the message was: The underlying connection was closed: An unexpected error occurred on a receive.

By the way this is in Visual Studio 2019:

_05.NoSuchElementException.exe' (CLR v4.0.30319: _05.NoSuchElementException.exe): Loaded 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Private Assemblies\Runtime\Microsoft.VisualStudio.Debugger.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The program '[17312] _05.NoSuchElementException.exe' has exited with code -1 (0xffffffff).

Can someone help?

c#
selenium
selenium-webdriver
microsoft-edge
selenium-edgedriver
asked on Stack Overflow Dec 23, 2019 by Largent803 • edited Dec 23, 2019 by DebanjanB

2 Answers

0

This error message...

OpenQA SeleniumWebDriverException' in WebDriver.dll
An unhandled exception of type SeleniumWebDriverException' occurred in WebDriverdll
A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:52586/session. The status of the exception was Receive Failure, and the message was: The underlying connection was closed: An unexpected error occurred on a receive.

...implies that the EdgeDriver was unable to initiate/spawn a new Browsing Context i.e. Microsoft Edge Browser session.

Some more details about your Microsoft Edge and Microsoft EdgeHTML would have helped us to debug the issue in a better way. However, incase you are using EdgeHTML 18 or EdgeHTML 19, as per the documentation in Microsoft WebDriver:

Microsoft WebDriver for Microsoft Edge (EdgeHTML) versions 18 and 19 is a Windows Feature on Demand which ensures that it’s always up to date automatically and enables some new ways to get Microsoft WebDriver.


Steps

To configure you will have to enable Developer Mode:

Go to Settings > Update and Security > For Developer and then select "Developer mode".

To install run Microsoft Edge version 18 through an elevated command prompt:

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

tl; dr

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.

answered on Stack Overflow Dec 23, 2019 by DebanjanB
0

The most of your code is right except the last line. I modified it and tested with the following code and it can work well:

using System.Collections.Generic;
using System.Linq;
using OpenQA.Selenium;
using OpenQA.Selenium.Edge;

public class webdriver
{
    static void Main(string[] args)
    {    
        IWebDriver AzimaHome = new EdgeDriver();
        AzimaHome.Navigate().GoToUrl("http:www.msn.com");

        IList<IWebElement> terms = AzimaHome.FindElements(By.TagName("a"));
        terms.First(element => element.Text == "msn").Click();
    }
}

I think the error occurs mainly because the Microsoft WebDriver version you're using doesn't match the Microsoft Edge version you're using.

If you're using Microsoft Edge version prior to 18, you can download the appropriate webdriver for your installed version of Microsoft Edge in this link. If your Microsoft Edge version is 18 or higher, you can install the appropriate webdriver version according to the ways in this article.

answered on Stack Overflow Dec 24, 2019 by Yu Zhou

User contributions licensed under CC BY-SA 3.0