I have a custom wait method defined as:
public IWebElement WaitForElementClickable(IWebDriver _driver, By elementName)
{
var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(20));
return wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(elementName))
}
I have one place where I click on a button and a new page loads, it sticks on "loading" for a few seconds (2-3 secs) and then I want to click on something else once it loads....
public void enterSearchInfo()
{
//Thread.Sleep(2000);
IWebElement selectElement = utility.WaitForElementClickable(_driver, element);
selectElement.Click();
}
Even though I have the wait method set to 20 secs this only works 5 times out of 10, the other 5 times I get the following error...
OpenQA.Selenium.ElementClickInterceptedException: element click intercepted:
When I uncomment Thread.Sleep(2000) it works 10 out of 10 times
Is there a better way to handle this than the wait for element clickable method? I'd rather not be hardcoding sleep waits in my code.
WaitForElementClickable()it just clicks the element instead of passing it back.ElementClickInterceptedExceptionmessage usually contains the HTML of the element that it receiving the click... it's just not posted in the question for some reason. Not sure if that means that it wasn't in the message or was left out.