Dear all,
when I use the WaitForExists / WaitForNotExists method my desktop client AUT starts flashing heavily.
In this case, I know that it will take several minutes until the AUT is ready, so I would like to know if there is any possibility to tell WaitForExists that it should search for the UI element every few seconds instead of every few milliseconds.
I check the "Duration" property, but it seems not to do what I am looking for.
Any ideas?
Thank you, BR mrt
WaitForExists increase search delay?
Re: WaitForExists increase search delay?
Hi mrt,
I'm using this usercode to check status of a job in Sut, which needs an extra item to press to refresh my page ( you probably don't need this)
just added Thread.Sleep for your use case, so try and expirement wether it works:
public void RetryandWait(RepoItemInfo infoExists, RepoItemInfo atagRefresh, int secondstotry, int secondstowait )
{
var startTime = System.DateTime.UtcNow;
bool bfound = false;
while( (System.DateTime.UtcNow - startTime < TimeSpan.FromSeconds(secondstotry)) && (!bfound))
{
atagRefresh.FindAdapter<ATag>().Click();
bfound = infoExists.Exists();
Report.Log(ReportLevel.Info, "RetryandWait", "checking..." + bfound.ToString() );
Thread.Sleep (secondstowait);
}
if (!bfound) {throw new Ranorex.ElementNotFoundException("not found", null); }
}
I'm using this usercode to check status of a job in Sut, which needs an extra item to press to refresh my page ( you probably don't need this)
just added Thread.Sleep for your use case, so try and expirement wether it works:
public void RetryandWait(RepoItemInfo infoExists, RepoItemInfo atagRefresh, int secondstotry, int secondstowait )
{
var startTime = System.DateTime.UtcNow;
bool bfound = false;
while( (System.DateTime.UtcNow - startTime < TimeSpan.FromSeconds(secondstotry)) && (!bfound))
{
atagRefresh.FindAdapter<ATag>().Click();
bfound = infoExists.Exists();
Report.Log(ReportLevel.Info, "RetryandWait", "checking..." + bfound.ToString() );
Thread.Sleep (secondstowait);
}
if (!bfound) {throw new Ranorex.ElementNotFoundException("not found", null); }
}
Re: WaitForExists increase search delay?
Thank you, I ended up with this:
Code: Select all
[UserCodeMethod]
public static void WaitForExistsDelayed(RepoItemInfo itemInfo, Duration checkEvery, Duration totalTimeout)
{
System.Diagnostics.Stopwatch stopWatch = System.Diagnostics.Stopwatch.StartNew();
while (!itemInfo.Exists(2000) && stopWatch.Elapsed.TotalSeconds <= totalTimeout.TimeSpan.TotalSeconds)
{
Thread.Sleep(new TimeSpan(checkEvery));
}
if (stopWatch.Elapsed.TotalSeconds < totalTimeout.TimeSpan.TotalSeconds)
Report.Success("Wait", "Element '" + itemInfo + "' exists after '" + totalTimeout.TimeSpan.TotalSeconds + "' seconds.");
else
Report.Failure("Wait", "Wait for not exists failed after '" + totalTimeout.TimeSpan.TotalSeconds + "' seconds.");
stopWatch.Stop();
}