Page 1 of 1
How to get name of element from repository
Posted: Thu Feb 13, 2020 8:12 pm
by IvanT
I have element in repository with name ButtonOk (this name i gave) how can i get this name from user code?
Re: How to get name of element from repository
Posted: Thu Feb 13, 2020 10:14 pm
by N612
The easiest way: drag and drop the repository element into your code method. Ranorex will automatically create a repository object (if needed), and a variable to that specific element.
Otherwise, you can do it manually. Example below:
Code: Select all
var repo = SampleSolutionRepository.Instance;
var okButton = repo.PopupWindow.OkButton;
Re: How to get name of element from repository
Posted: Fri Feb 14, 2020 10:29 pm
by IvanT
no.
i have method:
private void Example(Ranorex.Text Element, expectedValue){
if(Element.getattributevalue<string>("text").equals(expectedValue)){
report.success(here i want to take name of element in repository, not his parameter "name" )
Re: How to get name of element from repository
Posted: Sat Feb 15, 2020 1:05 am
by N612
Ah, I see. The name is available on the repository items "Info" object. This means you will need to ask for a
RepoItemInfo instead of a
Ranorex.Text. If calling this from code, you can get the info object by adding "Info" to the end of the repository item name (example below). If calling from a recording module, Ranorex will automatically pass the repository info object to the method.
Code: Select all
private void Init()
{
var repo = SampleSolutionRepository.Instance;
var okButton = repo.MyForm.OkButtonInfo;
myMethod(okButton);
}
public void myMethod(RepoItemInfo buttonInfo)
{
Report.Success(buttonInfo.Name);
}