FireFox中的Selenium OpenQA.Selenium.DriverServiceNotFoundException [英] Selenium OpenQA.Selenium.DriverServiceNotFoundException in FireFox

查看:425
本文介绍了FireFox中的Selenium OpenQA.Selenium.DriverServiceNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开始编写Selenium测试,而我编写的第一个非常基本的测试由于OpenQA.Selenium.DriverServiceNotFoundException异常而失败.

I'm trying to get started writing Selenium tests, and the first very basic test I write fails with the exception OpenQA.Selenium.DriverServiceNotFoundException.

using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;

namespace WebDriverDemo
{
        class Program
    {
        static void Main(string[] args)
        {
            IWebDriver driver = new FirefoxDriver();
            driver.Url = "http://www.google.com";

        }
    }
}

调试器说我需要下载geckodriver.exe并将其设置在我的PATH变量上,这已经完成,但仍然会出现相同的异常.当我对ChromeDriver做同样的事情时,它工作正常.

The debugger says I need to download geckodriver.exe and set it up on my PATH variable, which I've done, and I still get the same exception. When I do the same thing with a ChromeDriver, it works fine.

此外,根据 MDN ,如果我使用的是Selenium 3.0或更高版本,则应默认启用它.我正在Windows 10计算机上使用Selenium 3.0.1.

Also, according to the MDN, if I'm using Selenium 3.0 or later, it should be enabled by default. I'm using Selenium 3.0.1 on a Windows 10 computer.

推荐答案

您可以使用System.setProperty()方法将geckodriver位置添加到PATH中,也可以仅将其添加到代码中.

You can either add the geckodriver location in PATH or add it in the code only, using System.setProperty() method.

在下面的链接中查看.它显示了Java中的基本代码,您需要编写等效的C#.但是它提到了使用GeckoDriver的步骤.如果仍然无法使用,请分享您得到的错误.

Have a look at this below link. It shows the basic code in Java, you would need to write the C# equivalent. But it mentions the steps for using GeckoDriver. If its still not working then please share the error that you get.

http://www.automationtestinghub.com/selenium-3-0-launch-firefox-geckodriver/

这篇关于FireFox中的Selenium OpenQA.Selenium.DriverServiceNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆