Reputation: 13
I have recently changed my WebDriver from Firefox to ChromeDriver and the wait steps I previously used to wait until an element could be interacted with no longer works"
WebDriverWait w = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
w.IgnoreExceptionTypes(typeof(StaleElementReferenceException), typeof(InvalidElementStateException));
w.Until(ExpectedConditions.ElementExists(By.Id("formSubmit")));
I now often get errors like "Element is not clickable at point (964, 776). Other element would receive the click: " for example, even though the element is visible on the page.
Is there a way of telling the webdriver to wait until an element can be interacted with, or better, any settings that I could change to let Selenium know that I'm using Chrome so that my existing code works?
Upvotes: 1
Views: 1395
Reputation: 17
There is more than one way.
This is my favourite:
try {
// For example
site.FindElement(By.Id("ctl00_ContentPlaceHolderBody_drp_City")).Click();
}
catch {
Thread.Sleep(/* <Time in seconds> */);
site.FindElement(By.Id("ctl00_ContentPlaceHolderBody_drp_City")).Click();
}
Upvotes: 0
Reputation: 16201
Latest version of Selenium C# Binding(2.46) provides a method to Expected Conditions named ElementToBeClickable
. Try that instead. This is a very common issue with Chrome though.
Upvotes: 1