OpenQA.Selenium.WebDriverException: 'Cannot start the driver service on http://localhost:20548/'

后端 未结 2 954
你的背包
你的背包 2021-01-23 06:33

I\'m getting the following error when I try to open the EdgeDriver.

OpenQA.Selenium.WebDriverException: \'Cannot start the driver service on http://localhost:20         


        
相关标签:
2条回答
  • 2021-01-23 06:57

    OpenQA.Selenium.WebDriverException: 'Cannot start the driver service on http://localhost:20548/'

    As for this issue, It could be the case that a process of the WebDriver is still running in the background. Please try to fire up Task Manager to see and end it if does.

    Otherwise, you could try to use the following code to assign the webdeiver server:

            var driverpath = @"C:\Program Files (x86)\Microsoft Web Driver"; //find the web driver path
            var driver = new EdgeDriver(driverpath);
            // Navigate to Bing
            driver.Url = "https://www.bing.com/";
    
            // Find the search box and query for webdriver
            var element = driver.FindElementById("sb_form_q");
    
            element.SendKeys("webdriver");
            element.SendKeys(Keys.Enter);
    
            Console.ReadLine();
            driver.Quit();
    

    This version of MicrosoftWebDriver.exe is not compatible with the installed version of Windows 10.

    Please check this article to download the related Microsoft WebDriver version based on your Edge browser version.

    Then, you could refer to this article to use WebDriver.

    0 讨论(0)
  • 2021-01-23 07:09

    I tried running MicrosoftWebDriver.exe that was in the bin directory of my project (project name, Test). This gave me the answer I needed.

    I downloaded the correct driver from the following website:

    https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/#downloads

    ========================================================

    Further Update & Solution: How to know which driver to get ...

    I finally found the correct driver. There are two ways to get the driver.

    1. By downloading it from the Microsoft developer website
    2. Find it in the visual studio NuGet manager and let the manger configure it into your project (preferred method)

    Method 1: how to know which driver to download

    1. Go to the Microsoft developer website
    2. Find the Release which has a Release number equal to the version number on your Edge browser
    3. Configure your project to locate and use the MicrosoftWebDriver.exe you downloaded

    Method 2: how to know which driver to download

    1. Open your test project in VS and open the NuGet package manager
    2. Browse for the Selenium.WebDriver.MicrosoftWebDriver
      • Find the version of the webdriver where the last half of the version number matches the last half of your edge browser's Microsoft EdgeHTML version number (not obvious at all).
    3. Click in install button. everything will automatically be configured in your project so you can automatically start using the driver

    4. Add the few lines of Selenium code to your test project which will open the edge browser (shown in the original question).

    0 讨论(0)
提交回复
热议问题