Mobile Test Automation : App gets installed for every test case execution

For every test case is it mandatory to include the “Mobile device connection” activity, or is there is any way I could configure it so that I could use the existing mobile device connection for all the test cases?

Because I notice the app gets installed for every test case execution.

It is possible to reuse a connection. On the Mobile Device Connection activity there are 3 important properties that helps with this:

  1. You can create an empty Mobile Device Connection and set the OutputConnection property to some variable. If you set the first Mobile Device Connection Close property to Never then at the end of the execution of that activity, the connection will not close, so it can be reused further.
  2. If you create another connection and you set the InputConnection to the saved variable, that connection will be reused.

Now in order to do this across workflows, you need to have arguments to those workflows in which to pass the common connection and you can use the Invoke workflow activity to invoke those other workflows with the reused connection.

So the main workflow will look like in the image below:

And the invoked workflow will look like below.

Notice the input argument that is used to pass the saved connection.

Make sure that all the Mobile Device Connection activities have the Close property set to Never.

@phaserescu

Am not able to see the input/output connection in properties tab.(Community Version : Studio Pro 2020.10.6). Please help

Hello! We’ve just published version 21.3.0-preview on the official feed that contains the newly added properties InputConnection and OutputConnection. Can you update the package and check if it works? Thank you.

Best regards,
Alex Maxim.

Thanks a lot Alex. Working fine now

I’m not sure what do you mean by test cases. If you run everything in a single session, it should be possible.

Yeah for tests it probably isn’t possible. I tested with SauceLabs and the session remains open even after a test finishes, so if the connection is serialized and deserialized in some way it should be reusable. I tried some quick things but I didn’t get very far.

but if there are multiple test case in run then sauce reset device connection in next test case run how to preserve app state like logged in - during next test case run?

Right now you can’t unless you execute everything in a single big TestCase and then rely on asserts to split your test cases. So your testcase becomes a big container for invoke workflow activity and in each workflow you can start with a verify expression activity that has the title “Test Login started”, and it’s always true, so it gets reported in orchestrator. At the end you can finish with another always true assert with a title like “Test Login ended”. So when your big test fails, you can identify relatively fast, what workflow failed.

I know what I’m proposing isn’t ideal, but it might be an acceptable workaround.

1 Like

Hi @phaserescu ,

Can you please help me, How to make it work using Browserstack real devices, I have a multiple test cases with same login steps, So I am trying to invoke my login script but every time it is installing the app showing Login window

Hi @basi.reddy

I’ve attached a sample using our public test app “The App” for Android.

SeparateLogin.zip (74.0 KB)

  1. In the main.xaml there is a Mobile Device Connection activity that starts the connection, taps on Login and saves the connection to mobileConnection variable.
  2. After this the variable mobileConnection is sent to LoginSample.xaml to execute the “fake” login sequence
  3. Then again in the main.xaml there is another Mobile Device Connection that returns to main screen. This Mobile Device Connection activity has the Close option to Always to close the connection at the end. All the others have the Close option set to Never.

I hope this clarifies things but if not, please show me what you’re doing now, what you expect and what you get?

Thank You @phaserescu

hello @phaserescu my test case is passing through given when and then section. i have used same connection in when and then section. i want to close the application after executing then section. how can we do so

Can you please elaborate a bit? I don’t understand at what you’re referring.

hi @phaserescu

after executing “then” block i wanted to close the android application

screenshots:

If you want to close the current Application you can try to use the Manage Other App Activity with the Terminate command.
If you want to close the session, then you have a Close option on the Mobile Device Connection that you can set to Always and at the end of the execution it should close the session.
If you reuse the Mobile Device Connection activity and previously you set Close to Never, then you can add another empty one at the end which re-uses the previous connection and that has Close set to Always and after that empty activity executes it should close the session.

hi @phaserescu it worked… i use manage other app activity with terminate command and used the previous connection in it and set close to always

great thank you…

Hi @phaserescu every time i open the application i get this message box

this is my test case architecture

in “given” section i have a outconnection variable from outputconnection and thus used the same variable in “when” “Then” and close property set to never

in “then” section i have used two connection the second will close the connection with close property set to always

what is your question @gaffar_shaikh ?

Hi @phaserescu

i am testing a simple login flow in android application… when i am login manually no message box is getting displayed but while same trying with UiPath tool it is displaying above message box… i don’t want the message box while automating with uipath