I've been racking my brain over why this isn't working. No matter what I do this will not work, so I'm hoping someone in the community can help me solve this issue.
The problem comes with a custom function I've written for waiting if an element is visible or not. I have several other function that do other explicit waits that all seem to have the same issue. I recently updated my code to turn off implicit waits while executing explicit waits to get a correct wait time. This is when I noticed my code was not working at all. Below is my code snippet, I have an ajax modal that when it's triggered i need to wait for specific items to be there and that modal gets re-used which is why i need explicit instead of implicit waits for certain scenarios. The code below throws a NoSuchElement exception instead of ignoring and waiting for it. Any ideas??
public boolean elementVisible(By by, long seconds) {
WebDriverWait wait = new WebDriverWait(this.driver, seconds);
return wait
.ignoring(StaleElementReferenceException.class)
.ignoring(NoSuchElementException.class)
.pollingEvery(300, TimeUnit.MILLISECONDS)
.until(ExpectedConditions
.visibilityOfElementLocated(by)) != null;
}