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

Mobile Testing, Android App Testing.
dhale
Posts: 84
Joined: Thu Feb 27, 2014 7:33 pm

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

Post by dhale » Thu Jun 25, 2020 10:05 pm

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?

dhale
Posts: 84
Joined: Thu Feb 27, 2014 7:33 pm

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

Post by dhale » Thu Jun 25, 2020 10:10 pm

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.

dhale
Posts: 84
Joined: Thu Feb 27, 2014 7:33 pm

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

Post by dhale » Thu Feb 04, 2021 5:31 pm


LatunBiy
Posts: 1
Joined: Tue Feb 09, 2021 8:31 pm

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

Post by LatunBiy » Tue Feb 09, 2021 8:37 pm

Thank you for your help , everything is fine with this version.