Why won't my waits work - Implicit Wait, Explicit Wait?

Viewed 104

I am clearly missing something fundamental here, I have tried:

Explicit Wait

waitForMe = new WebDriverWait(driver, TimeSpan.FromSeconds(60));          
var headerInSearchResults = driver.FindElementByXPath("/Window/Window/Pane/Custom/Text");
waitForMe.Until(pred => headerInSearchResults.Displayed);

Implicit Wait

driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(60);

And neither of these approaches is working. So would somebody be able to point out where I might be going wrong? As this is frustrating the heck out of me!

Please note this is testing a desktop application via Appium WinAppDriver in C#. So iOS / Android type solutions won't work.

1 Answers
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60));

wait.IgnoreExceptionTypes(typeof(NoSuchElementException));

var header = wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("/Window/Window/Pane/Custom/Text")));

You have to specify exception types to ignore (this is quite counter-intuitive, I totally agree)

Related