Relative path from repository item

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
User avatar
Nicklas
Posts: 20
Joined: Mon Sep 26, 2011 2:53 pm
Location: Sweden

Relative path from repository item

Post by Nicklas » Thu Oct 17, 2013 3:12 pm

Hi,
We have a piece of user code where we need to get the relative path from a repository item, is that possible? We know about GetPath(), but that only gives us the absolute path, right?

/Nicklas

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Relative path from repository item

Post by Support Team » Fri Oct 18, 2013 11:18 am

Hello Nicklas,

This is possible using "GetPath(PathBuildMode buildMode, Element relativeToElement)".
Please read the forum post Relative Rxpath to windows controls to get more information.

Regards,
Bernhard
.
Image

User avatar
Nicklas
Posts: 20
Joined: Mon Sep 26, 2011 2:53 pm
Location: Sweden

Re: Relative path from repository item

Post by Nicklas » Tue Oct 22, 2013 9:09 am

Thanks, however this is not what I meant, the question was not accurate. What I meant was: is there a way to get the xpath part of a repository item, i.e.
MyRepository
-MyDOM
--MyFolder :: //div[#'myDivID]
---MyItem :: ./input[@class='myClass']

We want to get the xpath of the MyItem without the basepath (which is the xpath of MyFolder).

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Relative path from repository item

Post by Support Team » Tue Oct 22, 2013 4:30 pm

Hi,

In order to get the RxPath of the item you need the RepoItemInfo object of the repository item. This object has an attribute named "Path" which returns the RxPath of the item.
Ranorex.Core.Repository.RepoItemInfo itemInfo = repo.RootItem.RepoItemInfo;
Report.Info("Path: "+itemInfo.Path);
Regards,
Markus
.
Image