Abhi3106
Abhi3106

Reputation: 139

Selenium Explicit wait usage in C#

Earlier i used to use Expected Conditions class to wait for an element to display.

Since ExpectedConditions class is obselete now, I am using the below piece of code to specify my webdriver to wait for 30 seconds beforing throwing no such element exception. Is this code valid and meaningful? If not, please suggest the usage.

WebDriver wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
 wait.Until(d=>driver.FindElement(By.ID("")).Displayed);

Upvotes: 1

Views: 1955

Answers (1)

Vikas N
Vikas N

Reputation: 31

Go to "NuGet package manager" and install DotNetSeleniumExtras.WaitHelpers and then you will be able to use wait condition like, wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.UrlContains(URL));

Upvotes: 3

Related Questions