Microsoft launch driver for Edge

ms_edgeMicrosoft have announced a new WebDriver server for the upcoming new Windows 10 browser, Microsoft Edge. They announced support for automated testing of Microsoft Edge through the W3C WebDriver standard. To use WebDriver with Microsoft Edge, you need the MicrosoftWebDriver server on a Windows Insiders build of 10240 or newer. You can read their blogpost here at Bringing automated testing to Microsoft Edge through WebDriver.

Microsoft also provided a sample test using C# and the the as yet unreleased Edge bindings to open a webpage in MS Edge, navigate to bing.com and search for “webdriver”:

using System;
using System.IO;
using OpenQA.Selenium;
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;

namespace BingSearchTest
{
    public class Program
    {
        static void Main(string[] args)
        {
            RemoteWebDriver driver = null;
            string serverPath = "Microsoft Web Driver";
            try
            {
                if (System.Environment.Is64BitOperatingSystem)
                {
                    serverPath = Path.Combine(System.Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%"), serverPath);
                }
                else
                {
                    serverPath = Path.Combine(System.Environment.ExpandEnvironmentVariables("%ProgramFiles%"), serverPath);
                }

                // location for MicrosoftWebDriver.exe
                EdgeOptions options = new EdgeOptions();
                options.PageLoadStrategy = EdgePageLoadStrategy.Eager;
                driver = new EdgeDriver(serverPath, options);

                //Set page load timeout to 5 seconds
                driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(5));

                // Navigate to https://www.bing.com/
                driver.Url = "https://www.bing.com/";

                // Find the search box and query for webdriver
                RemoteWebElement element = (RemoteWebElement)driver.FindElementById("sbox");
                element.SendKeys("webdriver");
                element.SendKeys(Keys.Enter);

                // Wait for search result
                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
                wait.Until(x => x.Title.Contains("webdriver"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                if (driver != null)
                {
                    driver.Close();
                }
            }
        }
    }
}

Leave a Comment