Optimizing xpath expressions to find items faster
Posted: 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 :
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.
I'm kind of lost on where to optimize here. Any suggestion is appreciated!
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']
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!