Page 1 of 1

Add Android Endpoint via C#, then make Current Host?

Posted: Thu Jun 25, 2020 10:05 pm
by dhale
I'm trying to figure out how to add an Android endpoint using C# and then make it the Automation Root - But not by using Studio.
I've read several posts that kind of get at what I'm looking to do, but I'm not understanding something quite right and cant get things to work.

https://www.ranorex.com/forum/viewtopic ... 465#p54606
https://www.ranorex.com/forum/viewtopic ... int#p51229

We plan on using CI and Emulators to do Android testing. I'd like the setup of this to be as automated as possible.
That being said, what I cant figure out is how to set the automation root to the device I create using C# so that the "Deploy Android app" "Current Endpoint (None)" gets pointed at the device I created that is running in the emulator.

When I have 0 Endpoints manually pre-configured within Studio:
  • I do the logic as shown in AddEndpoint() to create the device. I give it a name such as 'emulator' and all of that works fine.
    Host.MakeCurrentHost("emulator") throws an error: Failed to set endpoint as element tree root. No endpoint with the name 'emulator' was found. There are 0 endpoints available: [].
    And ICollection<Ranorex.Core.Remoting.IRemoteEndpoint> allep = RemoteServiceLocator.Service.AllKnownEndpoints returns 1 entry that is my device I created via C#.
    But Host.AvailableHosts.ToList() only returns 1 entry for Localhost.

When I pre-create an endpoint manually using Studio
  • Host.AvailableHosts.ToList() contains both Localhost as well as my manually created 'emulator' entry
    Host.MakeCurrentHost("emulator"); works without error
    Host.CurrentHost returns "emulator"
How do I add a device and set it as to Host using just C#?
Is it possible? What am I missing here?

Re: Add Android Endpoint via C#, then make Current Host?

Posted: Thu Jun 25, 2020 10:10 pm
by dhale
Side note: we have 60 VM's and any one of them might be used for Android testing. I dont want to have to manually configure the VM's base image with endpoint logic.

I'd like to be able to set it all up in code, so that when we run the solution its all set up as a part of the test run.
That way even the other developers (and future developers) can get benefit from this setup logic.

Re: Add Android Endpoint via C#, then make Current Host?

Posted: Thu Feb 04, 2021 5:31 pm
by dhale

Re: Add Android Endpoint via C#, then make Current Host?

Posted: Tue Feb 09, 2021 8:37 pm
by LatunBiy
Thank you for your help , everything is fine with this version.