C# 即使引用了所有selenium DLL,也找不到InternetExlorerDriver
我试图通过运行一些示例来开始使用Selenium。我见过其他人在运行时让InternetExplorerDrive正常工作时遇到问题,请看,但我的问题不同。我得到一个编译时错误,找不到InternetExlorerDriver。我已经在我的项目中安装了所有四个“官方NuGet软件包:RC WebDriver WebDriverBackedElenium支持” 我也将IEDriverServer.exe添加到了项目中,但我还没有做到这一点 我遗漏了什么参考资料C# 即使引用了所有selenium DLL,也找不到InternetExlorerDriver,c#,selenium,selenium-webdriver,C#,Selenium,Selenium Webdriver,我试图通过运行一些示例来开始使用Selenium。我见过其他人在运行时让InternetExplorerDrive正常工作时遇到问题,请看,但我的问题不同。我得到一个编译时错误,找不到InternetExlorerDriver。我已经在我的项目中安装了所有四个“官方NuGet软件包:RC WebDriver WebDriverBackedElenium支持” 我也将IEDriverServer.exe添加到了项目中,但我还没有做到这一点 我遗漏了什么参考资料 using System; usin
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
您必须从selenium hq站点下载IE Explorer驱动程序才能调用Internet Explorer浏览器,因为selenium仅支持firefox作为其默认浏览器 请查看以下链接: 下载32位或64位internet explorer驱动程序服务器,只需在脚本中添加以下设置:
System.setProperty("webdriver.ie.driver",
System.getProperty("user.dir") + "\\IEDriverServer.exe");
Webdriver driver = new InternetExplorerDriver();
假设您已将exe文件保存在同一项目文件夹中。希望这有帮助 我注意到,在代码中,IE驱动程序的名称空间没有
using
语句。在源代码中添加以下行:
using OpenQA.Selenium.IE;
看看这是否解决不了问题
此外,在代码中,您试图实例化一个名为InternetExlorerDriver
的类。您缺少一个p
。InternetExpLorrDriver是您想要的
顺便说一句,Visual Studio应该为您提供工具提示支持以更正此问题。这在C#中不起作用,请参见,很遗憾,这是我正在尝试的,但它不起作用,因为我得到了一个缺少引用的编译时错误。忽略它并在某些时候运行Visual Studio会产生无用的引用错误:-)就是这样,拼写错误。谢谢