How can I restart android app via C#?

Mobile Testing, Android App Testing.
User avatar
sincoew
Posts: 48
Joined: Mon Nov 19, 2012 7:42 am

How can I restart android app via C#?

Post by sincoew » Wed Dec 05, 2012 4:40 am

I use below code to restart android app for each test case,
But executed a section of the time, It will cause app crash.

It's below code has any warning?

Code: Select all

Host.Local.CloseApplication(repo.ComAppC5Sample.Self, new Duration(0));
Delay.Milliseconds(3500);
Host.Local.RunMobileApp("Device", "com.App.Sample"); 
Thanks for your help.
Best Regards,
Robert Chen.

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

Re: How can I restart android app via C#?

Post by Support Team » Wed Dec 05, 2012 1:48 pm

Hello,

Your code below looks like OK.
Have you tried to start your app within the Recorder?

Could you please try our sample app (see 'Android Testing')?
Please take a look at our section 'Troubleshooting' in our User Guide.

Regards,
Markus (T)
.
Image

User avatar
sincoew
Posts: 48
Joined: Mon Nov 19, 2012 7:42 am

Re: How can I restart android app via C#?

Post by sincoew » Thu Dec 06, 2012 4:58 am

Hi Markus,

This issue look like our app cache do not clear when test-automation restart app.
Does Ranorext has any function can clear app cache? (such as kill process)

Best Regards,
Robert Chen

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

Re: How can I restart android app via C#?

Post by Support Team » Thu Dec 06, 2012 10:19 am

Hello Robert,

Ranorex does not have a function to clear/kill app cache.
You could do that with 'App Cache Cleaner' e.g.

Regards,
Markus (T)
.
Image

User avatar
sincoew
Posts: 48
Joined: Mon Nov 19, 2012 7:42 am

Re: How can I restart android app via C#?

Post by sincoew » Tue Dec 11, 2012 8:56 am

Hi Markus,

Thanks you for your help.

'App Cache Cleaner' can clear cache, (It's by manual)
but how can I clear cache when run each test case? (via code)
and if app no response, how can I do?

Best Regards
Robert Chen.

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

Re: How can I restart android app via C#?

Post by Support Team » Tue Dec 11, 2012 5:03 pm

Hello,

I have added this as a feature request into our system.

I got a custom method from our developers in order to clear app cache.
Please take a look at the attached file.

Regards,
Markus (T)
Attachments
ClearAppCache.txt
(771 Bytes) Downloaded 342 times
.
Image

User avatar
sincoew
Posts: 48
Joined: Mon Nov 19, 2012 7:42 am

Re: How can I restart android app via C#?

Post by sincoew » Wed Dec 12, 2012 9:27 am

Hi Markus,

Thanks a lot,
Which indeed resolved the issue for me.
I also kill process via adb.

Best Regards,
Robert Chen.

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

Re: How can I restart android app via C#?

Post by Support Team » Wed Dec 12, 2012 10:28 am

Hello,

You are welcome :-)

Regards,
Markus (T)
.
Image