Page 1 of 1

How to access repository elements/controls using code?

Posted: Thu Jul 09, 2015 5:59 pm
by sunil.pandey
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

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

Posted: Fri Jul 10, 2015 7:43 am
by odklizec
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.

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

Posted: Tue Jul 14, 2015 9:40 am
by sunil.pandey
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

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

Posted: Tue Jul 14, 2015 11:12 am
by odklizec
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.

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

Posted: Wed Jul 15, 2015 5:48 am
by subodh4u7
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;