c# - 使用 IE 浏览器运行测试用例时 C# 中的 Selenium

标签 c# selenium

<分区>

我正在研究 C# 中的 selenium webdriver。当我运行测试用例测试浏览器IE时,出现这个错误:

Test method AgileTravelUITests.GoogleSearchTest.TestIE threw exception: OpenQA.Selenium.DriverServiceNotFoundException: The IEDriverServer.exe file does not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at http://selenium-release.storage.googleapis.com/index.html.

我尝试使用 IEDriverServer_x64_2.53.0.zip 下载并安装 2.53 文件夹,但这没有用。

这是我的代码:

[TestMethod]
public void TestIE()
{
    IWebDriver driver = new InternetExplorerDriver();

    driver.Navigate().GoToUrl("http://www.google.com");

    IWebElement element = driver.FindElement(By.Name("q"));

    element.SendKeys("Hello Selenium WebDriver!");

    element.Submit();
}

我的代码现在在 IE 中运行良好。您可以点击此链接 Not able to launch IE browser using Selenium2 (Webdriver) with Java Java和C#是一样的。希望对您有所帮助。

最佳答案

下载 IEDriverServer_x64_2.53.0.zip 后,将 zip 解压缩到计算机上的本地驱动器。

确保将路径添加到提取 IEDriverServer.exe

的位置
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Support.UI;

IWebDriver driver = new InternetExplorerDriver(@"path\to\where you extracting the IEDriverServer");
driver.Navigate().GoToUrl("http://www.google.com");

注意:- 我建议您下载 32 位 IEDriverService.exe,因为 64 位 IEDriverService.exe 非常非常慢执行。

关于c# - 使用 IE 浏览器运行测试用例时 C# 中的 Selenium,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38605747/

相关文章:

python - WebDriver异常: Message: chrome not reachable after long time

python - 使用 selenium python 单击 svg

node.js - Protractor 发送键不工作 : an x display is required for keycode conversions

c# - 如何防止 XtraGrid TextEdit 在将光标移动到内容之外时失去焦点

c# - Entity Framework 对于小型企业应用程序来说会不会太过分了?

python - 在 python 中使用 selenium 连接到已经运行的 chrome 实例

java - Selenium 和 xpath : finding a div with a class and onClick function not working

c# - 使用哪个 Micro ORM?

c# - 不能通过并发线程访问破坏数据

c# - void Start() 未被调用