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";
}
}
}
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.
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.
Another option is to install Selenium.Firefox.WebDriver NuGet package which will copy the driver to the bin folder.
Then you can provide path to the current folder to driver ctor to run your tests:
IWebDriver driver = new FirefoxDriver("./");
I solved the problem by adding geckodriver.exe to my project and choosing "Copy if newer" for its Copy to Output Directory property.
This allows both regular code and NUnit tests to find the driver. No changes to PATH or SetProperty calls required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With