Reputation: 23
I am new to Testing and have been learning from a Udemy course. I tried to use explicit wait in a test where I am opening two differenct Urls.before clicking on the second Url, I want to have a wait for 30 seconds but my test finishes in only 10 to 13 seconds.
[TestMethod]
public void InterrogatingIWEBElements()
{
var driver = getChromeDriver();
driver.Navigate().GoToUrl("http://www.ultimateqa.com/automation/");
var myelement = driver.FindElement(By.XPath("//*[@href='http://courses.ultimateqa.com/users/sign_in']"));
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
IWebElement element = wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[@href='http://courses.ultimateqa.com/users/sign_in']")));
myelement.Click();
}
WebDriver Method
private IWebDriver getChromeDriver()
{
var outputDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
return new ChromeDriver(outputDirectory);
}
Upvotes: 0
Views: 130
Reputation: 143
The explicit wait here tells the driver to try and find the element for 30 seconds. If it finds the element it then ends the wait and continues execution. The explicit wait here means you want to wait for this specific element for some time while on the other hand an implicit wait will happen whenever you try to get an element.
If for some reason you need to wait for 30 seconds you can use the Thread.Sleep(TimeSpan.FromSeconds(30)) method - however do not use it to wait for an element to load.
Upvotes: 1