我在嘗試使用 C# 和 NUnit 在 Visual Studio (16.11.10) 中運行簡單的 UI 測驗時遇到了麻煩。我正在使用 Selenium.Firefox.WebDriver 0.27.0 版,Selenium.WebDriver 和 Selenium.Support 都是 4.1.0
測驗:
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
namespace ClassLibrary2
{
public class Class1
{
[Test]
public static void TestBrowser()
{
IWebDriver driver = new FirefoxDriver();
driver.Url = "https://login.yahoo.com/";
driver.Quit();
}
}
}
運行此測驗我收到這樣的錯誤:
? TestBrowser
Source: Class1.cs line 10
Duration: 4,6 sec
Message:
OpenQA.Selenium.WebDriverException : Cannot start the driver service on http://localhost:59898/
Stack Trace:
DriverService.Start()
DriverServiceCommandExecutor.Execute(Command commandToExecute)
WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
WebDriver.StartSession(ICapabilities desiredCapabilities)
WebDriver.ctor(ICommandExecutor executor, ICapabilities capabilities)
FirefoxDriver.ctor(FirefoxDriverService service, FirefoxOptions options, TimeSpan commandTimeout)
FirefoxDriver.ctor(FirefoxOptions options)
FirefoxDriver.ctor()
Class1.TestBrowser() line 18
Standard Output:
Unable to connect to the remote server
使用 ChromeDriver 一切正常。謝謝你的幫助。
uj5u.com熱心網友回復:
可能Selenium.Firefox.WebDriver 版本 0.27.0指向舊的GeckoDriver版本0.27.0。因此,您會看到錯誤。
解決方案是升級到 GeckoDriver 的最新版本,即version0.30.0
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/433039.html
