In my code I used Explicit Waits:
private WebDriverWait wait;
wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
I tried these methods:
wait.Until(ExpectedConditions.ElementExists(By.Id("<>")));
wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("<>")));
wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("<>")));
wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.LinkText("<>")));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("<>")));
But often it fails with these kinds of exception in different lines of code:
OpenQA.Selenium.StaleElementReferenceException: The element reference is stale.` Either the element is no longer attached to the DOM or the page has been refreshed.
OpenQA.Selenium.StaleElementReferenceException: Element is no longer valid
I can't find stable solution for this problems.
Could you help me with this, please?