I've a problem with long search time of web element using RxPath after several repeats in a loop. Searching time is dramatically different each time I run the same test. What can I do to make the search time the same every time i run the test in the loop?
I'm wondering why sometimes searching is fast otherwise is slow and after that searching time is again fast .
I'm using Ranorex 3 on Windows XP Pro sp3 and IE7
In real tests run in the loop search time of single element is longer then 15 second othewise 1 second is enough (the same element after few repeats of the loop).
Below is example that uses "Web Testing Example Page".
private static void Test()
{
for (int i=0;i<50;i++)
{
System.Diagnostics.Process.Start("iexplore.exe", "http://www.ranorex.com/web-testing-examples");
int defTimoOut = WebDocument.DefaultSearchTimeout;
WebDocument.DefaultSearchTimeout = 60000;
WebDocument webDocument = "/dom[@caption='Ranorex Test Page']";
WebDocument.DefaultSearchTimeout = defTimoOut;
Mouse.DefaultMoveTime = 30;
Keyboard.DefaultKeyPressTime = 10;
Delay.SpeedFactor = 1.0;
WebElement tag = null;
bool foundInput;
foundInput = webDocument.TryFindSingle(".//.[@id='testname']", 105000, out tag);
if (foundInput)
{
tag.Focus();
tag.Click();
Keyboard.Press("Test");
}
foundInput = webDocument.TryFindSingle(".//.[@id='testcolor']", 105000, out tag);
if (foundInput)
{
tag.Focus();
tag.Click();
ListItem item;
Host.Local.TryFindSingle("/container[@caption='selectbox']//listitem[@accessiblename~'^blue']", 105000, out item);
if (item != null)
{
item.Select();
item.Click();
}
}
webDocument.Close();
}
}