How to optimize rxpath

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
WajdaW
Posts: 75
Joined: Wed Jan 05, 2011 6:45 pm

How to optimize rxpath

Post by WajdaW » Wed Jan 05, 2011 7:00 pm

I had an rxpath from earlier, which wasn't flexibile as we waned to be, so I needed it to rewrite rxpath to become more flexibile. I did that, but now takes about 4 min and 20 sec to find element, and with earlier expresion it took only about 4-5 seconds.

Difference is only at the end at 'tr', 'td' and 'a' elements.

OLD ONE:
/dom[@domain='192.168.177.3:9080']/body/div/div/div/div/table/tbody/tr/td[@innertext='Presentation View']/../../../../../../div[2]/div[1]/div[2]/div[1]/div[1]/iframe[1]/body[1]/table[1]/tbody[1]
/tr[5]/td[{0}]/a[1]
where {0} is column parameter in string format

NEW ONE:

/dom[@domain='192.168.177.3:9080']/body/div/div/div/div/table/tbody/tr/td[@innertext='Presentation View']/../../../../../../div[2]/div[1]/div[2]/div[1]/div[1]/iframe[1]/body[1]/table[1]/tbody[1]
/tr/td/a[@innertext='{1}']/../../td[{0}]/a[1]

where {0} is column parameter in string format and
{1} is name of label

So basically I want to send to my method a type of label and rxpath should find item in the same row, and 2nd column.
Something like this example: http://www.ranorex.com/support/user-gui ... html#c2462

Is there a way to speed up this search, because 4 minutes are really long...
Or if there is some other way to make this work faster.

regards, Vajda

WajdaW
Posts: 75
Joined: Wed Jan 05, 2011 6:45 pm

Re: How to optimize rxpath

Post by WajdaW » Thu Jan 06, 2011 3:14 pm

I made some progress.
I tested various xPath expressions and got some results:
/dom[@domain='192.168.177.3:9080']//a[@innertext='any uri item']/../../td[2]/a[1] 2:40

/dom[@domain='192.168.177.3:9080']/body/div/div/div/div/table/tbody/tr/
td[@innertext='Presentation View']/../../../../../.././/a[@innertext='any uri item']/../../td[2]/a[1] 2:15

/dom[@domain='192.168.177.3:9080']/body/div/div/div/div/table/tbody/tr/
td[@innertext='Presentation View']/../../../../../..//a[@innertext='any uri item']/../../td[2]/a[1] 1:10

I haven't got faster time than 1:10, each fastest search is around this time.

I got instantly search only by expression that is not with parameter - not flexible

/dom[@domain='192.168.177.3:9080']/body/div[3]/div[1]/div[2]/div[1]/div[2]/div[1]
/div[1]/iframe[1]/body[1]/table[1]/tbody[1]/tr[5]/td[2]/a[1]

All other expressions give times between 1:30 and 3

1:10 is not bad, but compared to instant search(takes only < than 2 secs) is really slow.
Does anyone have any idea how to speed up this?

regards,
Vajda

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

Re: How to optimize rxpath

Post by Support Team » Fri Jan 07, 2011 1:07 pm

Generally, the search time is proportional to the number of elements searched, i.e. the more elements Ranorex needs to search the more time will be needed. With RanoreXPath that means the less defined an RanoreXPath is the more elements need to be searched and thus the longer the search will take. This is especially true when you use the "//" operator that instructs Ranorex to search all descendants for an element that applies to the part of the RanoreXPath following the "//" operator.

For your example that means the sooner (from left to right) you omit indexes or use the "//" operator in your RanoreXPath the more elements need to be searched and the longer the search will take. When you are searching a table, the search time is also dependent on how many cells need to be searched until the element is found, i.e. at which index the required item appears in the list. There is not much you can do in terms of editing the RanoreXPath to speed up search time if you want the flexibility you currently have in your paths.

However, there are a few things you can do to speed up search time in general:
  • If performing tests with Internet Explorer, make sure that the Ranorex Internet Explorer addon is installed.
  • Do not always use the complete absolute path, but create a rooted folder in the repository (with "Use Cache" enabled) for a common parent element and add an item to it using a relative path. That way, Ranorex does not always have to search for the parent element again.
    If you don't use Ranorex repositories, you can do the same by first searching for common parent element and then relatively searching for the actually wanted item.
  • If your table does not change over time, you can also use a CacheSessionContext. As long as the cache session context is active, Ranorex will only get the needed information once from Internet Explorer and will then work on the cached data, which is extremely fast. Try wrapping your code inside a CacheSessionContext like this:
    using (new CacheSessionContext())
    {
        // Put your code to access the table here!
        // Ranorex will not reflect changes made to the table inside this block!
    }
Regards,
Alex
Ranorex Team

WajdaW
Posts: 75
Joined: Wed Jan 05, 2011 6:45 pm

Re: How to optimize rxpath

Post by WajdaW » Tue Jan 11, 2011 3:49 pm

Support Team wrote:Do not always use the complete absolute path, but create a rooted folder in the repository (with "Use Cache" enabled) for a common parent element
How to do that?

Can you explain?

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

Re: How to optimize rxpath

Post by Support Team » Tue Jan 11, 2011 4:05 pm

Hi,

Please take a look to following documentation
http://www.ranorex.com/support/user-gui ... x-spy.html

Regards,
Peter
Ranorex Team