Different saerch time of WebElement in a loop

Ask general questions here.
Gismox
Posts: 2
Joined: Fri Sep 09, 2011 9:57 am

Different saerch time of WebElement in a loop

Post by Gismox » Fri Sep 09, 2011 10:05 am

Hello,
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();
        	}
        	
        }

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Different saerch time of WebElement in a loop

Post by Support Team » Fri Sep 09, 2011 2:20 pm

Hi,

as mentioned in our mail conversation I would suggest to optimize your RanoreXpaths to improve the permormance of your test scripts.

Regards,
Tobias
Support Tea,
.
Image