This method helps you to wait till Progress bar still on page.
public void HoldTillPageSynchronizationCompletes()
{
bool isPageInProgress = HoldTillElementIsVisible(By.CssSelector("div[class=Progress]"), 5);
if (isPageInProgress)
{
var stopWatch = new Stopwatch();
stopWatch.Start();
while (stopWatch.Elapsed.TotalMinutes < _waitTimeOut)
{
string isPageStillInProgress = WebDriver.FindElement(By.CssSelector("table[id=mydivimg]")).GetAttribute("style");
if (isPageStillInProgress.Contains("display: none;"))
{
stopWatch.Stop(); break;
}
}
}
}
This method helps you to wait till search records visible on page.
public void HoldTillRecordLoadInPageCompletes()
{
bool isLoadRecordInProgress = HoldTillElementIsVisible(By.CssSelector("div[style='display: block;']"), 5);
if (isLoadRecordInProgress)
{
var stopWatch = new Stopwatch();
stopWatch.Start();
while (stopWatch.Elapsed.TotalMinutes < _waitTimeOut)
{
string isLoadRecordStillInProgress = WebDriver.FindElement(By.CssSelector("div[id=load_Summary]")).GetAttribute("style");
if (isLoadRecordStillInProgress.Contains("display: none;"))
{
stopWatch.Stop(); break;
}
}
}
}
This is a common method helps you to hold for finding the element. In this element surely visible on the page but after sometime.
protected bool HoldTillElementIsVisible(By by, int timeOut = -1)
{
//Wait For Element
if (timeOut == -1)
{
timeOut = this._waitTimeOut;
}
try
{
WebDriverWait wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(timeOut));
wait.Until(ExpectedConditions.ElementIsVisible(@by));
return true;
}
//Exception Handling
catch (Exception)
{
return false;
}
}
public void HoldTillPageSynchronizationCompletes()
{
bool isPageInProgress = HoldTillElementIsVisible(By.CssSelector("div[class=Progress]"), 5);
if (isPageInProgress)
{
var stopWatch = new Stopwatch();
stopWatch.Start();
while (stopWatch.Elapsed.TotalMinutes < _waitTimeOut)
{
string isPageStillInProgress = WebDriver.FindElement(By.CssSelector("table[id=mydivimg]")).GetAttribute("style");
if (isPageStillInProgress.Contains("display: none;"))
{
stopWatch.Stop(); break;
}
}
}
}
This method helps you to wait till search records visible on page.
public void HoldTillRecordLoadInPageCompletes()
{
bool isLoadRecordInProgress = HoldTillElementIsVisible(By.CssSelector("div[style='display: block;']"), 5);
if (isLoadRecordInProgress)
{
var stopWatch = new Stopwatch();
stopWatch.Start();
while (stopWatch.Elapsed.TotalMinutes < _waitTimeOut)
{
string isLoadRecordStillInProgress = WebDriver.FindElement(By.CssSelector("div[id=load_Summary]")).GetAttribute("style");
if (isLoadRecordStillInProgress.Contains("display: none;"))
{
stopWatch.Stop(); break;
}
}
}
}
This is a common method helps you to hold for finding the element. In this element surely visible on the page but after sometime.
protected bool HoldTillElementIsVisible(By by, int timeOut = -1)
{
//Wait For Element
if (timeOut == -1)
{
timeOut = this._waitTimeOut;
}
try
{
WebDriverWait wait = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(timeOut));
wait.Until(ExpectedConditions.ElementIsVisible(@by));
return true;
}
//Exception Handling
catch (Exception)
{
return false;
}
}
No comments:
Post a Comment