Switching between Automation Roots?

Mobile Testing, Android App Testing.
Machisperer
Posts: 7
Joined: Wed May 02, 2018 3:48 pm

Switching between Automation Roots?

Post by Machisperer » Fri Aug 31, 2018 6:58 pm

Hi,
The mobile app I'm testing needs to interact with another application on a desktop. In my test cases, user needs to perform certain actions on the mobile app and some other actions on the desktop. So my question is as follows:
Is it possible to programmatically switch between two automation roots (i.e. a mobile device and a desktop) within the same automated test case?

Thanks for any tips or suggestions...

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Switching between Automation Roots?

Post by Support Team » Mon Sep 03, 2018 1:42 pm

Hello Machisperer,

Thank you for your post.
In order to switch to a specific endpoint during test run, the following codeline can be used:

Code: Select all

Host.MakeCurrentHost("Name of your Endpoint");
If you want to switch from an endpoint to the desktop, please use the following line:

Code: Select all

Host.MakeCurrentHost("Localhost");
regards,
Stephan
.
Image

Machisperer
Posts: 7
Joined: Wed May 02, 2018 3:48 pm

Re: Switching between Automation Roots?

Post by Machisperer » Thu Sep 06, 2018 5:15 pm

Thanks Stephan! Exactly what I needed

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Switching between Automation Roots?

Post by Support Team » Fri Sep 07, 2018 11:19 am

Perfect!
I'm glad, I could help.

Kind regards,
Stephan
.
Image

jsmith
Posts: 28
Joined: Mon Mar 05, 2018 4:03 pm

Re: Switching between Automation Roots?

Post by jsmith » Tue Oct 23, 2018 10:26 am

Does anyone have any clue as to apply the lessons above to multiple endpoints? I want to run the same test suite through each of my endpoints, one after the other...

qwertzu
Posts: 178
Joined: Wed Jan 25, 2017 11:08 am

Re: Switching between Automation Roots?

Post by qwertzu » Tue Oct 23, 2018 3:01 pm

Hi,

I would suggest creating a batch file that runs the test on all your endpoints.
In your output folder you can find shortcuts for each of your endpoints.
EndpointShortcuts.png
EndpointShortcuts.png (25.79 KiB) Viewed 86 times
You can run a test on a specific endpoint if you run the related shortcut.

So in your case, you could create a batch file that executes all shortcuts one after the other.

regards, qwertzu

jsmith
Posts: 28
Joined: Mon Mar 05, 2018 4:03 pm

Re: Switching between Automation Roots?

Post by jsmith » Tue Oct 23, 2018 3:14 pm

Thanks qwertzu, I shall look into that option once I have exhausted my current one. I can switch endpoint programmatically, so I can create a list of my endpoints, and loop through each of those list items, executing the test suite on each. At least, that is the idea.
So far, I have two unknowns:
Unknown One:
Can I run a whole test suite from code? i.e :

Code: Select all

public static void runatest()
        {
        	MyProject.Specific_Test.Start();
        }
This will run one test case (an .rxrec in my case). But I want to run:

Code: Select all

public static void runaproject()
        {
        	MyProject.Start();
        }
This would run a whole .rxtst

Unknown two:
Can I get a list of endpoints programmatically?

Thats where I'm at at the moment, any pointers or advice would be much appreciated.

jsmith
Posts: 28
Joined: Mon Mar 05, 2018 4:03 pm

Re: Switching between Automation Roots?

Post by jsmith » Tue Oct 23, 2018 3:26 pm

Unknown two is solved:

Code: Select all

List<string> available_hosts = new List<string>();
            	
            	
            	available_hosts = Host.AvailableHosts.ToList();
            	
            	foreach( string possibility in available_hosts)
            	{
            		Report.Log(ReportLevel.Info, possibility);
            	}

jsmith
Posts: 28
Joined: Mon Mar 05, 2018 4:03 pm

Re: Switching between Automation Roots?

Post by jsmith » Thu Nov 01, 2018 10:30 am

jsmith wrote:
Tue Oct 23, 2018 3:14 pm
Thanks qwertzu, I shall look into that option once I have exhausted my current one. I can switch endpoint programmatically, so I can create a list of my endpoints, and loop through each of those list items, executing the test suite on each. At least, that is the idea.
.......
....
But I want to run:

Code: Select all

public static void runaproject()
        {
        	MyProject.Start();
        }
This would run a whole .rxtst

Just revisiting this this morning. Can anyone advise if they have successfully started a whole test suite from code?

jsmith
Posts: 28
Joined: Mon Mar 05, 2018 4:03 pm

Re: Switching between Automation Roots?

Post by jsmith » Fri Nov 02, 2018 4:31 pm

Okay so I have found a solution.
I have created an excel document which lists the name of each of my endpoints.
Then set this document as a datasource for my test case
I have then created a User code to change Endpoint to whatever string I pass in as a parameter.
Then I have bound the data to the recording.
And set the input parameter for the User code call as a variable.

This is working pretty much perfectly.