Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

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

When searching for explicit waits with Selenium and C# I find several posts with code that looks similar to the Java-Counterpart:

for example here:

WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0,0,5));

wait.Until(By.Id("login"));

or here:

WebDriverWait wait = new WebDriverWait(driver, 30);

wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("locator")));

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

BUT:

When I try to code this myself in Visual Studio (getting Selenium package via NuGet), using WebDriverWait in my code will prompt the message:

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

Even though I am including the Selenium reference via

using OpenQA.Selenium;

When looking up the documentation for WebDriverWait you will find, that there should be a namespace called

OpenQA.Selenium.Support.UI

But I cannot access it via "using" in my code.

Why does this happen? Where can I find the WebDriverWait class?

1 Answer

0 votes
by (62.9k points)
edited by

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

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>

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...