How to start selenium with firefox driver

Viewed 1992

I try to follow this link: http://www.seleniumhq.org/docs/03_webdriver.jsp

In SetUpTest:

protected IWebDriver driver;
protected ISelenium selenium;
[SetUp]
public void SetupTest()
{
    driver = new FirefoxDriver();
    selenium = new DefaultSelenium(
        "localhost", 
        4444,
        "*chrome",
        "http://localhost");
    selenium.Start();
    verificationErrors = new StringBuilder();
}

When this line driver = new FirefoxDriver(); execute, I have this error:

Additional information: Cannot find a file named '***[Link to my project]\webdriver.xpi' or an embedded resource with the id 'WebDriver.FirefoxExt.zip'.

When I change it to driver = new ChromeDriver();, it opens firefox, but it cannot find element although element already render.

How to make selenium works with firefox?

1 Answers

If you was using C#, this appears that you have added Nuget packages of both Selenium .NET binding and Firefox Driver

I was following this tutorial https://docs.microsoft.com/en-us/vsts/build-release/test/continuous-test-selenium#create-the-test-project. It asks to add all these packages

After the project is created, you must add the Selenium and browser driver references used by the browser to execute the tests. Open the shortcut menu for the Unit Test project and choose Manage NuGet Packages. Add the following packages to your project:

Selenium.WebDriver

Selenium.WebDriver.ChromeDriver

Selenium.WebDriver.IEDriver

Selenium.Firefox.WebDriver

Selenium.WebDriver.PhantomJS.Xplatform

This is wrong. If you are using Firefox driver, you only need Selenium.WebDriver (maybe Selenium.Support as well) and Selenium.Firefox.WebDriver. You don't need Selenium.WebDriver.PhantomJS.Xplatform which will add the wrong WebDriver.dll into your project and the test run will complain about missing .json and .xpi file.

Related