How to access repository elements/controls using code?

Ask general questions here.
sunil.pandey
Posts: 11
Joined: Fri Jul 03, 2015 5:35 pm

How to access repository elements/controls using code?

Post by sunil.pandey » Thu Jul 09, 2015 5:59 pm

Hi,

Please help me understanding "How to access repository elements/controls using code?"

Suppose if have multiple modules where "Login" is one of them and my structure is to keep repository for the modules under one common folder named "Repository"

So Login repository will look like "Repository"-> LoginRepository

At the same time I am going to write my scripts, Test Cases under "Script" folder
Script-> LoginTestCases
Script-> MainPageTestCases

SO once I start writing test script in c#, I've to import or use the name space where repository belongs, correct? or any other way?

Thanks & Regards,
Sunil

How to access the login repository

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to access repository elements/controls using code?

Post by odklizec » Fri Jul 10, 2015 7:43 am

Hi,

I'm not sure what exactly you want to achieve and how looks your solution. Could you please post a sample solution so we can better understand your issue?

Basically, if you want to access the repository from code module, you need to instantiate repository in every code module you create, like this:
/// <summary>
        /// Holds an instance of the NameSpaceName.RepositoryName repository.
        /// </summary>
        private static NameSpaceName.RepositoryName repo = NameSpaceName.RepositoryName.Instance;
The above code is automatically added to cs file created with new recording module.
Last edited by odklizec on Tue Jul 14, 2015 11:13 am, edited 1 time in total.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

sunil.pandey
Posts: 11
Joined: Fri Jul 03, 2015 5:35 pm

Re: How to access repository elements/controls using code?

Post by sunil.pandey » Tue Jul 14, 2015 9:40 am

Hi Pavel,

Thank you for reply! :)

I got your point, let me clarify my question.

Suppose I've a test repository named as "Test" and have to write script named as "Login" so and both of these are in different folder.

For instantiating the repository class I've to use something like "using Repository.Login" correct?

Please let me know in case if I am not clear.

Best Regards,
Sunil

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to access repository elements/controls using code?

Post by odklizec » Tue Jul 14, 2015 11:12 am

Hi,

Sorry, but I still don't quite understand what you want to do? What's wrong with Ranorex way of doing things?

Each newly added Recording module (e.g. Login), has already instantiated default repository. So all you need to do is to start typing (in User Code) repo. and the Code Completion dialog should offer you a list of available repository elements and folders. Eventually, if you want to use Code Modules, you need to instantiate repository as described above.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
subodh4u7
Posts: 71
Joined: Tue Jan 06, 2015 8:26 am

Re: How to access repository elements/controls using code?

Post by subodh4u7 » Wed Jul 15, 2015 5:48 am

Hello sunil,
As far as i understood your query and below is the suggested solution what are you looking for:
u can add the below line on top of your namespace if you have kept your repository in the other interface(or project i.e. myRepository.rxrep is under the Repo folder in the project Repository)

using Repository.Repo;

In your module or class, using myRepo you will be able to access the elements/control in your code.
var myRepo= myRepository.Instance;
Regards,
Subodh