即使在引用所有selenium DLL之后也找不到InternetExlorerDriver

时间:2015-08-26 17:38:01

标签: c# selenium selenium-webdriver

我正试图通过运行一些样本来开始使用Selenium。我看到其他人在运行时遇到麻烦,让InternetExplorerDrive工作,请参阅How to instantiate InternetExplorerDriver with Selenium WebDriver using C#,但我的问题不同了。我得到一个编译时错误,无法找到InternetExlorerDriver。我在我的项目中安装了所有四个“官方NuGet包:RC WebDriver WebDriverBackedSelenium支持”。

我也将IEDriverServer.exe添加到项目中,但我还没有那么远。

我错过了什么参考?

using System;
using System.Threading;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;

namespace SeleniumTest
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create a new instance of the Firefox driver.

            // Notice that the remainder of the code relies on the interface, 
            // not the implementation.

            // Further note that other drivers (InternetExplorerDriver,
            // ChromeDriver, etc.) will require further configuration 
            // before this example will work. See the wiki pages for the
            // individual drivers at http://code.google.com/p/selenium/wiki
            // for further information.
            IWebDriver driver = new InternetExlorerDriver(); //missing reference error here

编译时间错误:

Error   1   The type or namespace name 'InternetExlorerDriver' could not be found (are you missing a using directive or an assembly reference?) c:\users\chadd\documents\visual studio 2013\Projects\SeleniumWebDr\SeleniumTest\Program.cs  22  37  SeleniumTest

1 个答案:

答案 0 :(得分:1)

我注意到在您的代码中,您没有IE驱动程序命名空间的using语句。将以下行添加到源代码中:

using OpenQA.Selenium.IE;

看看是否解决了这个问题。

此外,在您的代码中,您尝试实例化名为InternetExlorerDriver的类。您在那里错过了p。 InternetEx p lorerDriver就是您想要的。

顺便说一句,Visual Studio应该为您提供工具提示支持以纠正此问题。