【问题标题】:InternetExlorerDriver cannot be found even after referencing all selenium DLLs即使在引用所有 selenium DLL 后也找不到 InternetExlorerDriver
【发布时间】:2015-08-29 01:40:13
【问题描述】:

我正在尝试通过运行一些示例来开始使用 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

【问题讨论】:

  • 忽略它并运行视觉工作室一段时间会给出无用的参考错误:-)

标签: c# selenium selenium-webdriver


【解决方案1】:

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

using OpenQA.Selenium.IE;

看看这是否不能解决问题。

此外,在您的代码中,您正在尝试实例化一个名为InternetExlorerDriver 的类。您在那里缺少p。 InternetExplorerDriver 是您想要的。

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

【讨论】:

  • 就是这样,拼写。谢谢!
【解决方案2】:

您必须从 selenium hq 站点下载 IE Explorer 驱动程序才能调用 Internet Explorer 浏览器,因为 selenium 仅支持 firefox 作为其默认浏览器。

请在下面的链接中找到:http://www.seleniumhq.org/download/ 下载 32 位或 64 位 Internet Explorer 驱动程序服务器,然后在脚本中添加以下设置:

 System.setProperty("webdriver.ie.driver",
                System.getProperty("user.dir") + "\\IEDriverServer.exe");
    Webdriver driver = new InternetExplorerDriver();

假设您将 exe 文件保存在同一个项目文件夹中。希望这会有所帮助!

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-11-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-30
相关资源
最近更新 更多