Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.8k views
in Technique[技术] by (71.8m points)

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

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

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

The FirefoxDriver and ChromeDriver work just fine.

enter image description here

This is an issue with the driver?

There is nothing running on port 20548. The below code returns nothing.

C:WINDOWSsystem32>netstat -a -o | find "20548"

Did I need to do anything else besides downlowd the Selenium.WebDriver.MicrosoftWebDriver NuGet into my project?

enter image description here

The only software I need installed on my computer is the latest version of Microsoft Edge correct? enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...