zoukankan      html  css  js  c++  java
  • 在OpenQA.Selenium(C#)中找不到WebDriverWait类

    (从 Java-Selenium迁移到C#-Selenium)

    当使用Selenium和C#搜索显式等待时,我发现几个帖子的代码看起来类似于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支持类的单独包

    但:
    当我尝试在Visual Studio(通过NuGet获取Selenium包)自己编写代码时,在我的代码中使用WebDriverWait将提示消息:

    The type or namespace name ‘WebDriverWait’ could not be found (are you
    missing a using directive or an assembly reference?)

    即使我包括硒参考通过

    using OpenQA.Selenium;

    当查找documentation for WebDriverWait时,您会发现应该有一个命名空间

    OpenQA.Selenium.Support.UI

    但是我无法通过我的代码中的“使用”访问它.

    为什么会发生这种情况?在哪里可以找到WebDriverWait类?

     
    幸运的是,我有时也会将评论读到答案中,所以我在排名最高的评论 here中偶然发现了这个解决方案:

    WebDriverWait [is] from the OpenQA.Selenium.Support.UI namespace and
    comes in a separate package called Selenium WebDriver Support Classes
    on NuGet

    谢谢@Ved!

    在Visual Studio中,这意味着您需要安装TWO软件包:

    > NuGet包“Selenium.WebDriver”,而且
    > NuGet包“Selenium.Support

    来自Java与Maven,这不是微不足道的(至少对我来说),因为到现在为止,我只需要包含一个只有一个依赖关系来得到这样的“所有好东西”:

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.46.0</version>
    </dependency>

    *发布这个问题包括答案,因为花费我太多的时间和运气来绊倒答案.

  • 相关阅读:
    QT 开发小记
    linux c 时间函数
    ubuntu 16.04 登录后黑屏
    ubuntu 16.04 修正网卡与ifname对应关系
    HTML5 Shiv完美解决IE(IE6/IE7/IE8)不兼容HTML5标签的方法
    vue里面引入jq的方法
    如何禁用手机自带的输入法软键盘
    vue的首页渲染了两次的原因以及解决方法
    vue使用hightchats
    解决微信小程序使用switchTab跳转后页面不刷新的问题
  • 原文地址:https://www.cnblogs.com/zhaiganggang/p/13806922.html
Copyright © 2011-2022 走看看