![](/img/trans.png)
[英]Using Baseclass.Contrib.SpecFlow.Selenium.NUnit to run tests in @Browser:Firefox (C#/Specflow)
[英]Cannot start firefox browser instance for tests using Visual Studio, C#, Nunit and Selenium
我在嘗試使用 C# 和 NUnit 在 Visual Studio (16.11.10) 中運行簡單的 UI 測試時遇到了麻煩。 我正在使用 Selenium.Firefox.WebDriver 版本 0.27.0., Selenium.WebDriver 和 Selenium.Support both 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 一切正常。 謝謝你的幫助。
可能Selenium.Firefox.WebDriver version 0.27.0指向version0.27.0的舊版GeckoDriver 。 因此您會看到錯誤。
解決方案是升級到最新版本的GeckoDriver即版本 0.30.0
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.