How can I parameterize part of object in repository

Ask general questions here.
Ruser
Posts: 24
Joined: Wed Oct 07, 2009 3:26 pm

How can I parameterize part of object in repository

Post by Ruser » Wed Nov 18, 2009 9:19 pm

Hi,

I have an object in repository like this:

element[@id='hdyPastGrid']/element[3]/element/listitem/text[@caption='Test']

what I want to do is to parameterize that "caption='Test'" part. Make this caption of a parameter class I defined before. I can't use regular expression here because I want the caption to be specific.

Thanks,

Ruser

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 can I parameterize part of object in repository

Post by Support Team » Fri Nov 20, 2009 10:33 am

There are many things you could meaning with this question, but if you have a look at the user guide. The topic RanoreXPath: http://www.ranorex.com/support/user-gui ... xpath.html. It has a section on using the path in code. Also in version 2.2 of Ranorex you can use associated info property of the element in the Repository to change the path at run time.

Here you can find an example code for version2.2:
// The info item for following repo item: “repo.FlexTestPageDom.ContainerComboBox.Button3”
Report.Info(repo.FlexTestPageDom.ContainerComboBox.Button3Info.Name);
repo.FlexTestPageDom.ContainerComboBox.Button3Info.Path = "element[@id='hdyPastGrid']/element[3]/element/listitem/text[@caption='" + Test_Variable + "']";
Regards,
Ron
Ranorex Team

max
Posts: 8
Joined: Mon Oct 12, 2009 3:43 pm

Re: How can I parameterize part of object in repository

Post by max » Fri Nov 20, 2009 11:19 am

But you can also create a new Button-object/adapter of the dynamically created XPath in the code. That is even possible in the versions before 2.2. What is the advantage of the solution with the info poperty?

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 can I parameterize part of object in repository

Post by Support Team » Fri Nov 20, 2009 3:30 pm

max wrote:But you can also create a new Button-object/adapter of the dynamically created XPath in the code. That is even possible in the versions before 2.2. What is the advantage of the solution with the info poperty?
That's right. The advantage of the method stated by Ron is that you just need to adopt the path of a repository item once, e.g. at the beginning of your recording using a user code record item, and can leave the rest of the recording untouched. The repository item will have the changed path from then on.

Regards,
Alex
Ranorex Support Team