Reputation: 23
I tried the following code snippet in the Selenium C# WebDriver. (version 2.50+). I tested it with multiple functions (By.Xpath, By.ClassName, By.CssSelector, etc.)
var webDriver = new FirefoxDriver();
webDriver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 0, 60));
webDriver.Navigate().GoToUrl("http://google.com");
var resultElement = webDriver.FindElement(By.ClassName("NonExistingClass"));
Why doesn't this just return an empty collection or null or even a NoSuchElementException?I think it should not return a timeout exception.
Exception:
"An exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll but was not handled in user code
Additional information: The HTTP request to the remote WebDriver server for URL http://localhost:7055/hub/session/19e937df-9d51-4624-a700-33f0ec6be98c/element timed out after 60 seconds."
Upvotes: 2
Views: 6074
Reputation: 1505
You have provided a certain time span to wait. So driver will wait for that time and then if driver is not able to find that element on the page, it will throw timeout exception.
Just remove specified wait timespan to solve this problem.
I'm posting this answer because user: Kishan Patel didn't post this as answer to this question even though his comment solves the problem.
Upvotes: 4