1

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);
3
  • Look at the code that implements ExpectedConditions... what does it check for? Is it just .Displayed? Hint: no. Commented Sep 4, 2018 at 16:19
  • That is pretty much how you would use explicit waits, although a 30 second limit is quite high. Are you having any issues? Commented Sep 20, 2018 at 20:54
  • WebDriver wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); wait.Until(d=>driver.FindElement(By.ID("")).Displayed); I cannot wait until an element is Clickable using the above piece of code. looks like I will have to go with SeleniumExtras.WaitHelpers. Commented Sep 24, 2018 at 8:40

1 Answer 1

3

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));

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.