Reputation: 329
I added some breakpoint My test works in debug mode. But after deleting breakpoints I get Timeout exception. I used Thread.Sleep and it worked are there any alternatives rather than using thread.sleep
[Test]
public void OpenStockControl()
{
driver.Navigate().GoToUrl("http://testdeneme.com");
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1));
IWebElement userName = driver.FindElement(By.Id("LoginNew1_tU"));
userName.SendKeys("TEST3");
IWebElement userPassword = driver.FindElement(By.Id("LoginNew1_tP"));
userPassword.SendKeys("A7535");
IWebElement buttonSubmit = driver.FindElement(By.Id("LoginNew1_bGo"));
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
buttonSubmit.Click();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(20));
SwitchWindow("ABC MA", driver);
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(20));
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
IWebElement element = wait.Until(ExpectedConditions.ElementExists(By.Id("ext-gen54")));
element.Click();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
IWebElement element2 = wait.Until(ExpectedConditions.ElementExists(By.Id("ext-gen207")));
element2.Click();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
IWebElement element3 = wait.Until(ExpectedConditions.ElementExists(By.Id("ext-gen260")));
element3.Click();
}
Upvotes: 2
Views: 3592
Reputation: 262
Your waits (WebDriverWait) are waiting for 10 seconds for elements to appear. ExpectedCondition is not met and thus the Exception is thrown. You can increase the time amount in your call of WebDriverWait constructor.
Upvotes: 1
Reputation: 391
Have you looked at http://www.seleniumhq.org/docs/04_webdriver_advanced.jsp ? I have found that adding my own methods like bool WaitForPage([WebDriver],[Page],[time]) and its corollary WaitForNotPage(...) resolved many of the timeout issues. Explicit waits and implicit waits do solve many of them but you will still find yourself occasionally using Thread.Sleep().
Upvotes: 0