Hiroshi Kosaka
Hiroshi Kosaka

Reputation: 39

Exception occurs if you instantiate a EdgeDriver

Exception occurs if you instantiate a EdgeDriver.

【Exception Information】

An unhandled exception of type 'System.InvalidOperationException' occurred in WebDriver.dll

Additional information: No such driver (NoSuchDriver)

【StackTrace】

OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)

OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)

OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)

OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)

OpenQA.Selenium.Edge.EdgeDriver..ctor(String edgeDriverDirectory, EdgeOptions options)

ConsoleApplication.Program.Main(String[] args)

Environment is as follows.

Exception occurs in the following code.

IWebDriver webDriver = new EdgeDriver(serverPath, options);

using OpenQA.Selenium;
using OpenQA.Selenium.Edge;
using System.IO;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            string serverPath = "Microsoft Web Driver";
            if (System.Environment.Is64BitOperatingSystem)
            {
                serverPath = Path.Combine(System.Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%"), serverPath);
            }
            else
            {
                serverPath = Path.Combine(System.Environment.ExpandEnvironmentVariables("%ProgramFiles%"), serverPath);
            }
            EdgeOptions options = new EdgeOptions();
            options.PageLoadStrategy = EdgePageLoadStrategy.Eager;
            IWebDriver webDriver = new EdgeDriver(serverPath, options);     // Exception occured!!
            webDriver.Url = "https://www.google.co.jp";
            IWebElement element = webDriver.FindElement(By.Name("q"));
            element.SendKeys("test");
            element.Submit();
        }
    }
}

What kind of problems do will be considered?

Upvotes: 3

Views: 3181

Answers (1)

Clayton Martin
Clayton Martin

Reputation: 76

My first guess based on experience is that you're running the incorrect version of MicrosoftWebDriver.exe.

The executable is built with Windows but ships separately and takes a hard dependency on being the same build as the OS it's running on.

You can find what build of the OS you're on by following these steps:

  1. Go to Start > Settings > System > About and denote the OS Build.

    The releases so far are:

    • Windows 10 - TH1 - 10240
    • Windows 10 Fall Update - TH2 - 10586
    • Windows 10 Anniversary Update - RS1 - 14393
  2. Next you'll want to visit Micorosoft's WebDriver page and choose the appropriate download: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

Upvotes: 1

Related Questions