I have a bizarre problem at the moment, I am just making a start on some acceptance tests and went to NUGet the latest Selenium Webdriver. Installed fine and just wrote a quick test to prove it was all working:
[Test]
public void should_navigate_to_google()
{
var driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.google.co.uk");
}
The project is just a default class library using .net 4, everything included ok and I built and ran the test via Resharpers test runner. Then I got the error below:
OpenQA.Selenium.WebDriverException : An error occurred while
connecting to Firefox —-> System.IO.FileNotFoundException : Could
not load file or assembly ‘Ionic.Zip, Version=1.9.1.8,
Culture=neutral, PublicKeyToken=edbe51ad942a3f5c’ or one of its
dependencies. The system cannot find the file specified. at
OpenQA.Selenium.Firefox.FirefoxDriver.StartClient() at
OpenQA.Selenium.Firefox.FirefoxDriver..ctor() at
–FileNotFoundException at OpenQA.Selenium.Firefox.FirefoxExtension.Install(String profileDir) at
OpenQA.Selenium.Firefox.FirefoxProfile.InstallExtensions() at
OpenQA.Selenium.Firefox.FirefoxProfile.WriteToDisk() at
OpenQA.Selenium.Firefox.Internal.ExtensionConnection.Start() at
OpenQA.Selenium.Firefox.FirefoxDriver.StartClient()
I was a bit baffled and thought maybe I needed to use the .net 3.5 version of the library, no luck same error. I then tried going back to .net 4 and telling the assemblies to use SpecificVersion in the properties, still no luck.
Confirmed I am building for x86 and that firefox is installed in the default location, I have even given the firefox profile a link to the exe location, even made a firefox binary and told that where to look, still no luck. Then I sacked off the NUGet version and got the client driver binaries from the website, same issue.
After trying to switch versions and build for different CPU types I am out of ideas, there is very little documented about any issues like this, so here is some other information incase it is useful.
- Windows 7 Professional 64-bit
- Visual Studio 2010 Premium (with Resharper 6)
- Firefox 11 (installed to default location)
I tried using the internet explorer driver to make sure it wasn’t a firefox specific issue, and I get another error there which is shown below:
System.IO.FileNotFoundException : Could not load file or assembly 'Newtonsoft.Json, Version=4.0.6.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
at OpenQA.Selenium.Remote.Command.get_ParametersAsJsonString()
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(DriverCommand driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.IE.InternetExplorerDriver..ctor()
So now I am out of ideas and have wasted about 3 hours so far 🙁
I cannot help but laugh, I am crying inside though.
This is possibly one of the stupidest rookie mistakes ever, and I should have easily noticed my problem. I made 2 new projects, one to house some new unit tests, one to house acceptance tests. Then I went and pulled in all the dependencies for WebDriver into the acceptance test project and went about making a test in the Class1 file which was open to prove it all worked.
Then my problems started… What I failed to realise was writing the test in the unit-test project which Resharper happily included the WebDriver dll in the references for me, but I was running it thinking it was in the acceptance test project, which meant the assemblies listed were not available.
Anyway there is no real issue here, but just incase anyone is stupid enough to do the same thing as me I will leave this question here so people can point and laugh at the guy who used the wrong Class1.cs file 🙂