Page 1 of 1

Difference between Host.Local.FindSingle<Form>& Object repo

Posted: Sun Feb 19, 2017 11:59 pm
by pyedisane
Hi,

I have a bit of experience in Ranorex, I just want to understand the difference between using Host.Local.Findsingle<Form> and using the repository to find an element.

Which one would be quicker and reliable?

Do they make any difference?

It's just that with Host.Local.Findssingle, values(usually xpaths) assigned to variables are hard coded in the beginning of the script. Could this lead to performance issues?

Thank you

Re: Difference between Host.Local.FindSingle<Form>& Object repo

Posted: Thu Mar 09, 2017 9:27 am
by aaron03
I have also recently started thinking about this.

Re: Difference between Host.Local.FindSingle<Form>& Object repo

Posted: Fri Mar 10, 2017 1:48 pm
by McTurtle
Hello guys,

Reading this also made me curious. I tested it using the windows calculator as the repository object. What I did:

1. Create new Ranorex Test Suite
2. Create 2 Test Cases
3. The first Test Case (Using Findsingle) contains one recording with a user code action containing in the main method the following code:
var Multiply_Button = Host.Local.FindSingle(@"/winapp[@packagename='Microsoft.WindowsCalculator']/?/?/button[@automationid='multiplyButton']");
for(int i=0; i<20; i++)
{
Multiply_Button.As<Button>().Click();
Report.Info("Clicked on multiply button in Windows Calculator using Host.Local.FindSingle() 20 times." );
4. The second Test Case (Using Ranorex Respository) contains one recording with a user code action containing in the main method the following code:
var Multiply_Button=repo.Kalkulator.MultiplyButton;
for(int i=0; i<20; i++)
{
Multiply_Button.Click();
}
Report.Info("Clicked on multiply button in Windows Calculator using the Ranorex Repository 20 times." );
5. Run the Test Suite and get the report something like this:
Findsingle_vs_Repo.png
To your questions:

Which one would be quicker?
The repository. Why? Because of caching.

Which one would be more reliable?
The one that has the robuster RanoreXPath ;)

Do they make any difference?
Yes. If you are using the repository it provides for very good transparency and re-usability.

It's just that with Host.Local.Findssingle, values(usually xpaths) assigned to variables are hard coded in the beginning of the script. Could this lead to performance issues?
Both the Repository and variables you declare using Findsingle are hard. There should be no difference. What do you mean?

Regards,
McTurtle