Quickly change path in repository of multiple items

Ranorex Spy, Recorder, and Studio.
ElSticky
Posts: 34
Joined: Tue Sep 17, 2013 1:45 pm

Quickly change path in repository of multiple items

Post by ElSticky » Wed Apr 16, 2014 3:15 pm

Is there a way to rename all paths in a faster way then doing 1 by 1?

For example I want to:
page/page/button
rename to:
?//?//button

But I need to do this 30 times or more, can you change this at once?

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Quickly change path in repository of multiple items

Post by krstcs » Wed Apr 16, 2014 3:34 pm

My recommendation would be to get your favorite text editor (I use Notepad++) and do a search and replace in the rxrep file (it's just XML). Most of the good editors will do regex search and replace.

NOTE: BE VERY CAREFUL WITH THIS, for obvious reasons. You could end up with an invalid file. I would recommend backing up your rxrep file before doing this.
Shortcuts usually aren't...

ElSticky
Posts: 34
Joined: Tue Sep 17, 2013 1:45 pm

Re: Quickly change path in repository of multiple items

Post by ElSticky » Thu Apr 17, 2014 7:30 am

Thanks for the idea, I think that'll workout fine.

I was also curious why the performance when using '?' is like 20 times slower. I'm trying to make the tests hybrid now for design changes but they perform a lot slower. Any tips to make it faster?

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Quickly change path in repository of multiple items

Post by krstcs » Mon Apr 21, 2014 2:49 pm

Anytime a wildcard (?) or optional element (//) is used, Ranorex has to search every possible path under the parent until it either (a) finds the element or (b) reaches the COMBINED search timeout.

So, for example, if you have the following structure:

Code: Select all

<dom>
  <body>
    <div>
      <div/>
    </div>
    <div/>
    <div>
      <div id='myDiv'/>
    </div>
  </body>
</dom>
You would have the following paths, in order of greatest to least potential search times:

/dom[@domain='test.mydomain.com']//div[@id='myDiv'] -> Will search EVERY child under dom, and each child's children, recursively (i.e., it will search the whole dom structure), until it finds a div matching the id 'myDiv', or the search times out.

/dom[@domain='test.mydomain.com']/body/?/div[@id='myDiv'] -> Will search the dom for a body tag, and each child under body, and each child's children, to ONE level depth ONLY (i.e., it will just search one level deep in the structure under the body tag), until it finds a div matching the id 'myDiv', or the search times out.

/dom[@domain='test.mydomain.com']/body/div/div[@id='myDiv'] -> Will search the dom for a body tag, then it will search that body tag for each div. Then in each div, it will search until it finds a div matching the id 'myDiv', or the search times out.

/dom[@domain='test.mydomain.com']/body/div[3]/div[@id='myDiv'] -> Will search the dom for a body tag, then it will search that body tag for the 3rd div, then it will search the 3rd div for the div with the id 'myDiv'. (Try not to use indexes if possible, as they can become volatile as the developers move things around in the SUT.)


So, try to make your paths as specific as possible.

NOTE: If you use a unique ID (div[#'myDiv'] it will find it much more quickly since the unique id is hashed in a way that makes it easier to find, so Ranorex doesn't need to search recursively. This is why you should always try to use unique ids when available.
Shortcuts usually aren't...