1

I am sorry to ask this question. I have tried checking for a solution on here & through other sources. But, I could not get a solution.

I have also seen a few videos on YouTube. My code looks good. But I get errors on running the code in V/Studio on my PC.

Could it be due to a missing assembly reference ?

Here is the code:

using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

namespace Chrome_Driver_Launch
{
    class Program
    {
        static void Main(string[] args)
        {
            var driver = new ChromeDriver();
            driver.navigate().GotoUrl("http://google.com");

        }
    }
}

And here is the error:

CS0246 The type or namespace name 'OpenQA' could not be found (are you missing a using directive or an assembly reference?)

I also tried opening Firefox, Microsoft Internet Explorer, Microsoft Edge, & Opera from V/Studio & I could not get them to open. I guess it might be due to missing assemblies ?

Thank you.

OA345
  • 181
  • 2
  • 3
  • 10
  • Also, I have tried downloading the ChromeDriver from this website: https://chromedriver.storage.googleapis.com/index.html?path=2.27/ I selected: chromedriver_win32.zip I downloaded Release 10586 from https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ I was not able to add the relevant references to the bindings in V/Studio. Thank you very much. – OA345 Jan 20 '17 at 16:10

2 Answers2

1

You're missing a reference to Selenium Webdriver. Right click the project Chrome_Driver_Launch then click "Manage NuGet packages". In the opened tab click the browse tab and search for Selenium. Install the Webdriver package. If you already have the package you need to right click the project and click add reference, then add the reference.

Moshisho
  • 2,781
  • 1
  • 23
  • 39
  • 1
    I owe you one, mate.. Thanks.. That seemed to work. But, on running the code, I get the error: "An unhandled exception of type 'System.InvalidOperationException' occured in WebDriver.dll Additional information: unknown error: cannot find Chrome binary (Driver info: chromedriver=XXXXXXX) Thank you very much. – OA345 Jan 20 '17 at 18:16
  • You need to download chromedriver from here: https://sites.google.com/a/chromium.org/chromedriver/downloads and then you need to set the path for it like in this answer: http://stackoverflow.com/questions/13724778/how-to-run-selenium-webdriver-test-cases-in-chrome basically just by doing this `System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");` before your `new ChromeDriver()` statement – mrfreester Jan 20 '17 at 18:31
0

Thank you for all your help!

I downloaded the browser. That fixed the error. I have 2 laptops that I use & I remembered that I did not have the browser installed.

Installed it & error disappaered.

Many Thanks once again!

OA345
  • 181
  • 2
  • 3
  • 10