check if object exist with loop
Posted: Tue Jul 21, 2015 7:20 am
Hi,
I try to locate object in a page, and it can be randomly in 1 of 10 pages.
I find a solution but it take a long time (1 min to each page):
note:
I am using Ranorex studio 5.3.2
I try to locate object in a page, and it can be randomly in 1 of 10 pages.
I find a solution but it take a long time (1 min to each page):
Code: Select all
int i=0;
bool isObVisable= false;
while (i<10)
{
i++;
if (i==10)
{
Report.Log(ReportLevel.Info, "Obj Not founded", "Obj is not exist at this location. test will failed");
Report.Failure("Obj not exist", "Obj wasn't found, test can't continue");
throw new Ranorex.ElementNotFoundException("Item RanoreXPath with no return" , null);
}
try {
isObVisable = repo.Web.obj.Visible; // this section take a min, while finding when it exist take few secs.
}
catch (Exception ex)
{
Console.WriteLine("element wasn't found exception type: {0} ", ex.GetType().Name);
}
if (isObVisable)
{
Report.Log(ReportLevel.Info, "Obj found", "Obj was founded after " + i.ToString() + " pages and will be click");
repo.Web.obj.Click();
break;
}
else
{
nextPageBtn.Click();
}
}
I am using Ranorex studio 5.3.2