Optimizing xpath expressions to find items faster

Class library usage, coding and language questions.
Munro89
Posts: 17
Joined: Thu Feb 18, 2010 10:06 pm

Optimizing xpath expressions to find items faster

Post by Munro89 » Fri Mar 04, 2011 2:39 pm

We have an application where finding an item takes between 3 and 5 seconds. We have a form in particular where we want to validate quite a few text items, and we need to navigate between a tabs.

We have considered using a CacheSessionContext for each tab, but it still takes 3 to 5 seconds per tab for validations. Overall, validating this form takes higher than 20 seconds, and we need to validate it multiple times for our tests.

From what I understand with xpaths, every time we access an element, Ranorex will find from the Host all steps one by one. If we have this xpath expression :

Code: Select all

/form[@controlname='ZoneInfoForm']/container[@controlname='InfoPanel']/tabpagelist/tabpage[@controlname='AddressTab']/text[@controlname='CustomerValue']
What I understand is the form is searched first, the the container InfoPanel, etc.. up to our text CustomerValue.

Is there any way to optimize this so that the text item is found in less than 1 second? I thought about searching for the form, and then from the form, call a FindSingle method to actually search only from the form, but that didn't seem to help.

Code: Select all

var form = Repo.Instance.ZoneInfoForm.Self;
var textItem = form.FindSingle(Repo.Instance.ZoneInfoForm.InfoPanel.Tabs.TabAddress.textCustomerValueInfo.AbsolutePath);

I'm kind of lost on where to optimize here. Any suggestion is appreciated!

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Optimizing xpath expressions to find items faster

Post by Support Team » Mon Mar 07, 2011 9:51 am

Hi,

it looks like your path is not optimally chosen.
Does this bahviour only occurs on one machin, or on others too?
Can you provide us a snapshot of your application under test?
Following link will show you how to generate a snasphot file:
http://www.ranorex.com/support/user-gui ... html#c2072

Regards,
Tobias
Support Team

Munro89
Posts: 17
Joined: Thu Feb 18, 2010 10:06 pm

Re: Optimizing xpath expressions to find items faster

Post by Munro89 » Mon Mar 07, 2011 4:01 pm

Hi,

The speed is about the same from one computer to another.

I uploaded a snapshot of our application here :
http://www.mediafire.com/file/iv7xlop21 ... shot.rxsnp

Computer specs running the test :
Core 2 Duo (2ghz)
4gb ram
Windows 7 64bit

Thanks

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Optimizing xpath expressions to find items faster

Post by Support Team » Tue Mar 08, 2011 2:47 pm

Hi,

as I can see there should be no problems with using your search path and the system you are working on seems also not to be the problem.
Maybe there is a anti virus software, or similar, running on your machine which blocks.

Kind regards,
Tobias
Support Team