I Cannot get Selenium to work with the Firefox Driver on c#. Chrome works perfectly but not Firefox.
Using:
I have already set the path variable in Windows.
GeckoDriver is already installed in the Bin folder in sources.
The Firefoxdriverservice does not exist so cannot use that command.
The error im getting is "threw exception: System.ComponentModel.Win32Exception: The system cannot find the file specified"
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using System.Windows.Forms;
namespace BeatRecaptcha
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
IWebDriver driver = new FirefoxDriver();
driver.Manage().Window.Maximize();
//Go to Google
driver.Navigate().GoToUrl("www.google.co.uk");
}
}
}
Not sure if you recently upgraded to the latest version of selenium but since Selenium 3.0 you also need to download the geckodriver.exe from the below url as per your system configuration.
https://github.com/mozilla/geckodriver/releases
Then you can try something like this:
//Give the path of the geckodriver.exe
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(@"C:\Users\abcd\Downloads\geckodriver-v0.13.0-win64","geckodriver.exe")
//Give the path of the Firefox Browser
service.FirefoxBinaryPath = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
IWebDriver driver = new FirefoxDriver(service);
driver.Navigate().GoToUrl("https://www.google.com");
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