Gecko驱动在Firefox浏览器的C#中无法工作。

问题描述 投票:2回答:1

我试图使用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:

ERROR IMAGE我将感谢你的帮助,谢谢。

c# selenium firefox selenium-webdriver geckodriver
1个回答
0
投票

首先,你需要安装Firefox: 开发者版安装并更新。

在你的情况下,这`s应该是足够的。

源与完整的指南。

© www.soinside.com 2019 - 2024. All rights reserved.