我试图使用Selenium Webdriver和C#.Net为Firefox浏览器运行一些单元测试,但我无法做到这一点(Chrome和IE11浏览器可以顺利运行)。
以下是我收集到的信息。
操作系统:Windows 10 Enterprise
Gecko驱动版本:Geckodriver-v0.17.0-win32。
Mozilla Firefox版本:54.0.1 (32位)
已在 "C:\LEO\SELENIUM C#/Firefox "下设置了环境路径变量。
一段代码
using System;
using System.Text;
using System.Threading;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Firefox;
[TestFixture]
public class UnitTest3
{
private IWebDriver driver;
private StringBuilder verificationErrors;
private string baseURL;
[SetUp]
public void SetupTest()
{
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(@"C:\LEO\SELENIUM C#\Firefox");
service.FirefoxBinaryPath = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
driver = new FirefoxDriver(service);
baseURL = "http://www.dow.com";
verificationErrors = new StringBuilder();
}
}
错误。
消息:消息:OpenQA.Selenium.WebDriverException : Unable find matching set of capabilities: OpenQA.Selenium.WebDriverException : Unable to find a matching set of capabilities.
TearDown : System.NullReferenceException : 对象引用未设置为一个对象的实例。
StackTrace.TearDown : System.NullReferenceException : Object reference not set to an instance of an object:
我将感谢你的帮助,谢谢。