public static void SelectByIndex(this HtmlSelect control, int index, int maxTimeout)
{
try
{
DateTime start;
double timeElapsed = 0;
start = DateTime.Now;
while (control.Options.Count <= 1 && timeElapsed < maxTimeout)
{
control.Refresh();
timeElapsed = ((TimeSpan)(DateTime.Now - start)).TotalMilliseconds;
}
if (control.Options.Count() >= 1)
{
control.SelectByIndex(index, true);
Logger.Debug(string.Format("Inside HtmlSelectExtension , option available in {0}ms", timeElapsed));
}
else
{
Logger.Debug(string.Format("Inside HtmlSelectExtension , option not available in {0}ms", timeElapsed));
}
}
catch(InvalidOperationException e)
{
throw new GUIException(string.Format("InvalidOperationException exception, check if the items are within range :{0}", e.Message));
}
catch (ExecuteCommandException e)
{
throw new GUIException(string.Format("WebAii ExecuteCommand exception, check if the items are within range :{0}",e.Message));
}
}
}