Cannot find WebDriverWait class in OpenQA.Selenium (C#)

前端 未结 3 1563
感情败类
感情败类 2020-12-14 07:07

(Migrating from Java-Selenium to C#-Selenium)

When searching for explicit waits with Selenium and C# I find several posts with code that looks simil

相关标签:
3条回答
  • 2020-12-14 07:31

    Luckily I sometimes read the comments to answers as well, so I stumbled across the solution within the highest ranked comment here:

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

    Thanks @Ved!

    In Visual Studio this means, that you need to install TWO packages:

    • NuGet package "Selenium.WebDriver" AND ALSO
    • NuGet package "Selenium.Support"

    Coming from Java with Maven, this is not trivial (at least to me ;-), because until now I just needed to include one and only one dependency to get "all of the good stuff" like this:

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

    * Posted this as a question including the answer because it cost me too much time and luck to stumble over the answer.

    0 讨论(0)
  • 2020-12-14 07:32

    Selenium.WebDriver.WaitExtentions.

    0 讨论(0)
  • 2020-12-14 07:38

    Have you tried adding?

    using OpenQA.Selenium.Support.UI;
    

    That should be all you need. Depending on your IDE, it likely (?) will have a helper that will find and add missing references. I use Visual Studio. I just type what I know should be there. When the IDE puts red squiggles on WebDriverWait, I hover over it and it shows a tooltip that says I'm missing a reference and I click on the link, Show potential fixes. In the new tooltip it shows several options, usually the first of which is to add the using statement. I click that one and the red squiggles go away.

    I really like Visual Studio but I've been using Eclipse for the last 9 months or so and I prefer the way Eclipse handles this. I think it's more intuitive... but that's just me.


    EDIT

    Just wanted to make clear for future readers... I don't use NuGet. I just download the Selenium .Net package and drop the 4 DLLs in/near my project and then add references to all 4 of them to my Visual Studio project. Once I do that and use the instructions above, it works for me.

    0 讨论(0)
提交回复
热议问题