Optimizing xpath expressions to find items faster : Automation API

Optimizing xpath expressions to find items faster

Class library usage, coding and language questions.

Optimizing xpath expressions to find items faster

Postby Munro89 » Fri Mar 04, 2011 3: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!
Munro89
 
Posts: 17
Joined: Thu Feb 18, 2010 11:06 pm

Re: Optimizing xpath expressions to find items faster

Postby Support Team » Mon Mar 07, 2011 10: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
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: Optimizing xpath expressions to find items faster

Postby Munro89 » Mon Mar 07, 2011 5: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
Munro89
 
Posts: 17
Joined: Thu Feb 18, 2010 11:06 pm

Re: Optimizing xpath expressions to find items faster

Postby Support Team » Tue Mar 08, 2011 3: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
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests