【问题标题】:System.InvalidOperationException occurred in WebDriver.dll while doing automation testing in Firefox driver在 Firefox 驱动程序中进行自动化测试时,WebDriver.dll 中发生 System.InvalidOperationException
【发布时间】:2017-09-21 17:55:23
【问题描述】:

我已经更新了最新的 selenium webdriver (v 3.4.0) 并安装了最新的 firefox 驱动程序 (0.15.0)。我将这些安装在我正在通过“管理 Nuget 包”选项处理的项目中。突然间,我的所有测试都失败了,因为它无法与 Firefox 浏览器上的任何元素进行交互。为了说明我的问题,当我在谷歌网站上尝试以下简单测试时

IWebDriver driver = new FirefoxDriver();
driver.Url = "https://www.google.com/";
var MyKeyWord = driver.FindElement(By.Id("lst-ib"));
MyKeyWord.SendKeys("Gmail");

失败并出现以下异常。

An unhandled exception of type 'System.InvalidOperationException' occurred in WebDriver.dll

Additional information: Expected [object Undefined] undefined to be a string (IndexOutOfBounds)

我正在寻找如何处理这个问题,我找到了如下解决方案: driver = new FirefoxDriver(DRIVER_PATH);

但是我所有的测试都是在没有在 firefox 中指定这些路径的情况下执行的,因为当我们使用“管理 Nuget 包”选项安装所需的包时,firefox 会选择它们。我不知道为什么它突然开始失败。有人对此有什么建议吗?

【问题讨论】:

  • 如果你使用 geckodriver 0.16 会发生什么?
  • 我没用过。我正在检查它。只是想知道,它是否类似于驱动程序文件?

标签: c# selenium selenium-webdriver automated-tests selenium-firefoxdriver


【解决方案1】:

https://github.com/mozilla/geckodriver/releases下载最新的geckodriver。将其解压缩并将 gecodriver 文件放入您的系统路径。重新启动(如果需要)。

此链接将有助于设置:https://github.com/mozilla/geckodriver

我希望它会有所帮助。

【讨论】:

    【解决方案2】:

    NuGet 管理器中有两个 Chromedriver 显示 - 一个 Chrome 驱动程序,另一个是 Selenium Google Chrome 驱动程序。您必须同时安装两者,然后才能正常工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-07
      • 1970-01-01
      • 2020-10-25
      • 1970-01-01
      • 2015-04-18
      • 2016-01-14
      • 2023-04-09
      • 2017-06-06
      相关资源
      最近更新 更多