Page 1 of 1

How can I parameterize part of object in repository

Posted: Wed Nov 18, 2009 9:19 pm
by Ruser
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

Re: How can I parameterize part of object in repository

Posted: Fri Nov 20, 2009 10:33 am
by Support Team
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

Re: How can I parameterize part of object in repository

Posted: Fri Nov 20, 2009 11:19 am
by max
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?

Re: How can I parameterize part of object in repository

Posted: Fri Nov 20, 2009 3:30 pm
by Support Team
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