【发布时间】:2015-12-15 13:46:41
【问题描述】:
(从 Java-Selenium 迁移到 C#-Selenium)
在使用 Selenium 和 C# 搜索 explicit waits 时,我发现一些帖子的代码类似于 Java-Counterpart:
例如here:
WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0,0,5));
wait.Until(By.Id("login"));
或here:
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("locator")));
WebDriverWait 来自 OpenQA.Selenium.Support.UI 命名空间,并位于名为 Selenium WebDriver Support Classes 的单独包中
但是:
当我尝试在 Visual Studio 中自己编写代码时(通过 NuGet 获取 Selenium 包),在我的代码中使用 WebDriverWait 将提示消息:
找不到类型或命名空间名称“WebDriverWait”(您是 缺少 using 指令或程序集引用?)
即使我通过
包含了 Selenium 参考using OpenQA.Selenium;
当查找documentation for WebDriverWait 时,您会发现,应该有一个命名空间
OpenQA.Selenium.Support.UI
但我无法通过代码中的“使用”访问它。
为什么会这样?在哪里可以找到 WebDriverWait 类?
【问题讨论】:
标签: c# selenium selenium-webdriver