How Can I Modify Repository’s Template for Code Generation?

Ranorex Studio, Spy, Recorder, and Driver.
WHAuden
Posts: 1
Joined: Tue Jan 22, 2013 1:41 am

How Can I Modify Repository’s Template for Code Generation?

Post by WHAuden » Tue Jan 22, 2013 3:25 am

We are using Ranorex repository extensively for our web testing. The structure of our repository, almost always, represents the structure of our web pages.

For example if customer order page has the structure:

Code: Select all

Order->Customer->MailingAddress->StreetAddress
We organize the repository such that: “Order “ is the root; “Customer” is a folder under root; “MailingAddress” is a subfolder under "Customer" and naturally “StreetAddress” is an item under “MailingAddress” folder. With this structure in place, Ranorax generates a very intuitive class structure that allows us to access each elements of the page very easily.

So we can access StresstAddress by typing:

Code: Select all

Order.Customer.MailingAddress.StreetAddress
This is very nice but going forward, I would like to expand the inner most member: Repository item (In the example above that would be the StreetAddress item) by adding a few properties and methods.

For example I want to add a property called:

Code: Select all

ExpectedValue 
and a method called

Code: Select all

LoadFromDataSource(string DataSourceName)
so I can write:

Code: Select all

Order.Customer.MailingAddress.StreetAddress.ExpectedValue = “Hello”;
Or

Code: Select all

Order.Customer.MailingAddress.StreetAddress.LoadFromDataSource(“SqlServer");
These properties and methods are simple, always identical and tedious to write. It’s trivial to add these functions to Repository.cs but clearly they get overwritten every time something changes in the repository.

I assume that Ranorex uses a template similar to Visual Studio & T4 to generate the repository code. If there is such a template, it will be great if I can modify it to get Ranorex to automatically generate the code for our custom properties and methods.
  • Is there a way to modify the code generating template for the repository?
  • If there is, what steps are required to add custom methods and properties for each items in the repository?
  • Are there any other mechanisms in Ranorex that allows for automated creation of custom properties & methods for each items in the repository? (We already do use module variables)

We're open to any solution with the same effect.
Thanks

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 Modify Repository’s Template for Code Generation?

Post by Support Team » Wed Jan 23, 2013 8:41 am

Hello,

Unfortunately that's not possible in Ranorex to change some kind of a repository template, but you can create a new class which inherits the original repository class. With an instance of the new class you will have access to the repo items in the original repository.
E.g.
public class RepoExtension : OrigRepoClassRepository
{
   // add your methods and properties here
}
Is this an option for you?

Regards,
Bernhard