cancel
Showing results for 
Search instead for 
Did you mean: 

Running on a specific device, when 2 are connected, defaults back to the 1st connected.

SOLVED
Occasional Contributor

Running on a specific device, when 2 are connected, defaults back to the 1st connected.

I have a script that  tests a mobile application on 2 different iPads. It is all run through Jenkins and basically the parameters are passed from Jenkins to a text file and TC reads that text file into its Temporary Variables.

 

One of these Variables is called 'Device' and is the name of the, you guessed it, Device. I have 3 devices and if i connect device A to the pc and select it to run from Jenkins it runs fine. It is the same for devices B and C, as long as i only have 1 device connected.

 

It gets a bit more interesting if i have multiple devices connected,say in order A then B. Device A connected and run through jenkins runs fine, but if i select device B, 2nd connected, in Jenkins and run, it installs the application on device B, but then continues running on device A.

 

My code is written in Delphi and i set the Current Device straight from the name in the Variable, which is named the same.

 

procedure SetMobileDevice;
begin
  Mobile.SetCurrent(Project.Variables.Device, 1);
end;

And this is the code that stops running on the device selected and reverts back to the 1st device connected. This is in a different script, but same project than the code above.

procedure OpenAboutScreen;
var 
  TopNav                            : OleVariant;
begin
  TopNav := Aliases.Device.processApplication.window0.toolbar0;
  Topnav.Button('About').Click;
end;

I have connected the devices in a different order to prove it is reverting back to the 1st connected.

 

Any pointers or guidance would be appreciated

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: Running on a specific device, when 2 are connected, defaults back to the 1st connected.

Hi,

 

You did not mention it initially, but assuming that both devices are with iOS, I would say that you are getting expected behaviour.

> Aliases.Device.processApplication.window0.toolbar0;

The case here is that when TestComplete resolves the above line of code, it tries to find the device that meets its identification criteria - i.e. the device with iOS. As soon as such device is found, TestComplete continues with the found device (as it has no reasons to behave differently) and looks for the processApplication object on this device.

 

You may consider these options to cope with this problem:

a) Add device name as one more identification parameter for Device object and set it (parameter) to get its value from the project variable (which you initialize to the required value at test start);

b) If you can guarantee that processApplication is running on the device, you may switch to the Required Children pane for the Device object (see your screenshot) and set processApplication as a required child. With this setting, TestComplete will be instructed to identify device not only by the OS name, but also look for the running application. And if the application is not found for the first device, TestComplete will check another device.

 

Hope, the above made things more clear.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
4 REPLIES 4
Community Hero

Re: Running on a specific device, when 2 are connected, defaults back to the 1st connected.

Hi,

 

> Aliases.Device.processApplication

How Device object is mapped in your NameMapping?

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Occasional Contributor

Re: Running on a specific device, when 2 are connected, defaults back to the 1st connected.

Morning Alex,

 

Name mapping screenshot attached. Obviously have something setup incorrectly just not sure what.

Community Hero

Re: Running on a specific device, when 2 are connected, defaults back to the 1st connected.

Hi,

 

You did not mention it initially, but assuming that both devices are with iOS, I would say that you are getting expected behaviour.

> Aliases.Device.processApplication.window0.toolbar0;

The case here is that when TestComplete resolves the above line of code, it tries to find the device that meets its identification criteria - i.e. the device with iOS. As soon as such device is found, TestComplete continues with the found device (as it has no reasons to behave differently) and looks for the processApplication object on this device.

 

You may consider these options to cope with this problem:

a) Add device name as one more identification parameter for Device object and set it (parameter) to get its value from the project variable (which you initialize to the required value at test start);

b) If you can guarantee that processApplication is running on the device, you may switch to the Required Children pane for the Device object (see your screenshot) and set processApplication as a required child. With this setting, TestComplete will be instructed to identify device not only by the OS name, but also look for the running application. And if the application is not found for the first device, TestComplete will check another device.

 

Hope, the above made things more clear.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Highlighted
Occasional Contributor

Re: Running on a specific device, when 2 are connected, defaults back to the 1st connected.

Morning Alex,

 

Yes all devices are currently iPads so iOS devices.

 

I implemented your detailed option A, and that worked successfully. Looking at it now it was obvious.

 

Thank you so much for taking the time to look into this for me.

New Here?
Join us and watch the welcome video:
Top Kudoed Authors
Join the September Hub-bub to show off, learn and win