Using the thread,sleep user can pause the currant thread.But handling a simple waiting for a element is a bit advance thing,
Because this need more resources from the computer(mainly ram usage)
Because this need more resources from the computer(mainly ram usage)
1).Thread.Sleep(5000);
Using the webdriverwait:
2).WebDriverWait wait = new WebDriverWait(<webdriver>,<timetowait>);
eg:
WebDriverWait wait = new WebDriverWait(WebDriverInti.driver, TimeSpan.FromSeconds(5000));
wait.Until(ExpectedConditions.ElementExists(By.XPath("//*[@id=\"rdiv\"/h3/a")));
Using webdriverwait: (More advance way)
3).
WebDriverWait wait = new WebDriverWait(WebDriverInti.driver, TimeSpan.FromSeconds(5000));
wait.Until<IWebElement>((d) =>
{
IWebElement element = WebDriverInti.driver.FindElement(By.XPath("//*[@id=\"rso\"]/div[2]/li[1]/div/h3/a"));
if (element.Displayed && element.Enabled)
{
return element;
}
return null;
});
Using webdriverwait: (Friends way)
_driver = new ChromeDriver(@"C:\ChromeDriver", options, TimeSpan.FromSeconds(180));
Using webdriverwait: (Friends way)
_driver = new ChromeDriver(@"C:\ChromeDriver", options, TimeSpan.FromSeconds(180));
No comments:
Post a Comment